If my memory serves me right i think that the line .......
loop: Goto loop ' Endless Loop
...... will not kick the watchdog. You probably need to insert atleast one statement between the label and the goto.
/Ingvar
If my memory serves me right i think that the line .......
loop: Goto loop ' Endless Loop
...... will not kick the watchdog. You probably need to insert atleast one statement between the label and the goto.
/Ingvar
Tried that... Didnt help im afraid...
It looks like its not even making it out of the interrupt routine, and just locking up and resetting at some point after it turns on the led.
I think Ingvar's right. I'm not sure you're leaving any room for an interrupt to occur. Try it like this:
loop:
For y = 0 to 100
pause 1
Next y
Goto loop
well the interrupt is def occuring or the led wouldnt come on at all. an interrupt handled in assembly doesnt need "room" for it to occur. It will jump right to the interrupt handler no matter what the processor is doing at the time... but ill try what you suggest
*edit* just tried it and no change... when i press the button attached to the interrupt pin the led goes high for 2 secs and then the whole thing crashes and restarts
Last edited by Kamikaze47; - 16th November 2005 at 15:32.
I'm sorry. I just realized that. Do you reset you're interrupt flag somewhere? Should there be an Intf = 0 just before the retfie?
first off all you forgot to clear int flag
in your int handler so your PIC will always
be in interrupt routine. you have to put line
before retfie instruction.Code:bcf INTCON,1
also I suggest you to turn on and off
LED in int routine with little delay
in between (although it is not adviceable to use
delays in interrupt)
to see the interrupt more clearly. you can
use this int handler for example:
Code:asm int_handler ; Save Resisters ; movwf wsave ; Save W Register into wsave swapf STATUS,W ; Save STATUS Register into ssave clrf STATUS movwf ssave movf PCLATH,W ; Save PCLATH Register into psave movwf psave movf FSR,W ; Save FSR Register into fsave movwf fsave endasm high LED pause 100 low LED ; Interrupt Code ; ;bsf _LED ; Turn on LED asm ; Restore Resisters ; movf fsave,W ; Restore FSR Resister movwf FSR movf psave,W ; Restore PCLATH Resister movwf PCLATH swapf ssave,W ; Restore STATUS Resister movwf STATUS swapf wsave,F ; Restore W Resister swapf wsave,W bcf INTCON,1 retfie endasm
I would have thought the interrupt flag would be reset automatically when it returns from the interrupt handler. I havnt seen interrupt routines that reset the flag, but I guess its worth a try.
Ahh yep, that did the trick. Thanks Ingvar.
Just a single line at the end of the interrupt handler: bcf _INTF
You always have to clear interrupt flag in software
before retfie instruction. If you don't clear the flag,
instruction retfie will set GIE bit and PIC will be
interrupted again. Logical AND function beetwen
int flag bit and int enabled bit (AND-ed with GIE)
will result in interrupt.
Bookmarks