Interrupt with Basic
Remzi
Posts: 4
Hello,
I recently purchased the SX Tech board. I am trying to figure out the Interrupt rutine. My task is to use as a emergency stop and reset or go back to beginning of my program.
Please help me out with the pbasic software,·what·I need to do?
Thanks
I recently purchased the SX Tech board. I am trying to figure out the Interrupt rutine. My task is to use as a emergency stop and reset or go back to beginning of my program.
Please help me out with the pbasic software,·what·I need to do?
Thanks
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
You'll have to give more details if you want some detailed advise.
Bean.
I have 2 leds, RC.0 and RC.1
I'd like to Blink the RC.0 as a main program
when itterrupt happens RC.1 blinks 1 sec. end goes
back to where ever it's left
Here my code to be!!! What do I do wrong?
Thanks,
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
Led1·············VAR···· RC.0
Led2·············VAR···· RC.1
'
INTERRUPT
'
ISR_start:
·· HIGH LED2
·· PAUSE 1000
·· LOW LED2
ISR_Exit:
·· WKPND_B = %00000000····· ' Clear pending, enable interrupt
·· RETURNINT
'
PROGRAM Start··················· ' I dont know why I need this???
'
Start:
··· TRIS_C = %00000000······· ' port c output
··· WKED_B = %11111110······ ' rb.0 falling edge
··· WKEN_B = %11111110······ ' rb.0 is input
·· ·WKPND_B = %00000000···· ' Clear pending, enable interrupt
····HIGH Led1
····PAUSE 500
·· ·LOW Led1
··· PAUSE 500
·GOTO Start
END
·····
An ISR is supposed to be QUICK. Get in, set a flag, get out.
Check the flag in your upper level routine, and do something with it.
The problem you run into is that an ISR 'interrupts' your main routine. Thus it distorts the timing of your main routine. You want that distortion to be as small as possible.
The other problem you get is multiple triggers. With a slow ISR, additional triggers are either ignored, or cause re-entrancy into your ISR -- not a good thing.
simple what I'd like is to when iterrupt happens, stop the blinking led1, turn the led2 until reset.
Thanks,
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
Led1·············VAR···· RC.0
Led2·············VAR···· RC.1
'
INTERRUPT
'
ISR_start:
···LOW LED1
···HIGH·LED2
ISR_Exit:
·· WKEN_B = %11111111····· '·NO interrupt until reset
·· RETURNINT
'
PROGRAM Start··················· ' I dont know why I need this???
'
Start:
··· TRIS_C = %00000000······· ' port c output
··· WKED_B = %11111110······ ' rb.0 falling edge
··· WKEN_B = %11111110······ ' rb.0 is input
·· ·WKPND_B = %00000000···· ' Clear pending, enable interrupt
····HIGH Led1
····PAUSE 500
·· ·LOW Led1
··· PAUSE 500
·GOTO Start
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Pgm_ID:
DATA "SX/B Template", 0
Why do you have this? I think I doesnt do anything with ISR...
Thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office