Shop OBEX P1 Docs P2 Docs Learn Events
Disabling interrupts for serout SX/B — Parallax Forums

Disabling interrupts for serout SX/B

DunnseptDunnsept Posts: 115
edited 2006-06-11 00:19 in General Discussion
I'm adding a serial graphics LCD to my project. The help file says to disable interrupts before using serout
but I can't find in the docs the best way to do this.
Can I set OPTION at any time in code?
would something such as this work:

start:
   OPTION = $86    'int enable, prescalar = 128
 
main:
 
'blah  blah
'blah
'oops need serout
OPTION = $C6      'option reg stays same except bit 6 (RTI) is now 1
serout txpin,baud,"hi"
OPTION = $86     're-enable interrupts
'do stuff
goto main


right now I'm using the RTCC as a sort of timer.. even if my time periods wind up off by a few seconds because of this,
if it works, I don't mind.. I can adjust the time periods anyway.

thanks!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
stand back! I have a slide rule and I know how to use it!

Comments

  • BeanBean Posts: 8,129
    edited 2006-06-09 19:35
    Yes, Just set OPTION to disable the interrupts.
    Depending on the interrupt code, you might be able to adjust the baud rate to "factor in" the time spent in the interrupt.
    Can you post your interrupt routine ?
    What baud rate are you using ?
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • DunnseptDunnsept Posts: 115
    edited 2006-06-09 19:57
    hey bean:

    Mainly I'm playing around with the LCDs and will add one to the existing code I have for the coffee roaster and beer brewer.
    right now I'm using T9600 for baud and the LCD_OUT sub written by jon williams (thank you, jon)
    LCD supports 9600, 19,2 and 38,4
    this stuff is way cool.. no interrupts or anything right now, but I have it setup with my thermocouple.. top part of the display shows
    temp: 75F
    and then bottom part of display is a graph of temp vs time.. kinda like an autochart.. display scrolls to the right and keeps plotting temp
    I guess I could just slap an interrupt in there and see what happens... not like I'm gonna get much real work done today anyway

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
  • BeanBean Posts: 8,129
    edited 2006-06-09 20:21
    If the interrupt take "about" the same amount of time, you might get away with adjusting the serial baud rate.

    What you can do is keep adjusting the baud rate up in 1% increments until it starts working, then keep increasing it until it stops working again. Then use the average of the highest and lowest working values.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • DunnseptDunnsept Posts: 115
    edited 2006-06-09 20:51
    thanks.. I'll have to check the LCD specs.. as far as I saw, it said "supports 9600, 19,2 and 38,4" and I set those by sending commands to the controller.
    =0 sets 9600
    =1 sets 19,2
    =3 sets 38,4
    something to play around with this weekend.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
  • Dave HeinDave Hein Posts: 6,347
    edited 2006-06-10 01:31
    If your interrupt service routine is short you can probably leave interrupts enabled.· With a system clock of 4 MHz, the 9600 buad bit time is about 417 cycles.· This allows for a tolerance of about +/- 200 cycles.· If your ISR is less than 100 cycles you should not have a problem, assuming that you don't get more than one interrupt per transmitted byte.· At 19.2 or 38.4 things become a bit tighter.

    I'm working on a project where I get 100 interrupts per second.· My ISR increments a memory location and then returns, so it only uses a few cycles.· I've never seen a problem with serial input or output with interrupts enabled.


    ·
  • BeanBean Posts: 8,129
    edited 2006-06-10 02:21
    I didn't mean to change the baud rate of the LCD. I mean if your LCD is 9600 baud, then try using 9700 baud, then 9800 baud, then 9900 baud, and so on.
    Because the ISR will "slow down" the baud rate (because it takes time that is not accounted for). You need to adjust the baud rate up to account for it.
    This works best when the ISR is very short, and occurs often (at least several times each bit).
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • DunnseptDunnsept Posts: 115
    edited 2006-06-11 00:19
    ok thanks guys..

    I'm off to Toronto for a wonderful week of SAP Business Process Integration indoctrination.. I mean training.

    I'll check it out when I return

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
Sign In or Register to comment.