PDA

View Full Version : Interrupts 101



matador29b
- 26th January 2010, 00:46
Hello everyone. I am having a bit of a problem, this code (or it's equivalent) works merrily on assembler, but it seems to lose the declarations for the ports after if executes the interrupt routine.
Can anyone tell me what I am doing wrong? This code works ok, but as soon as it hits the asm routine, it stops working. The interrupt works, the sequence works, values are sent to the variable portc.3 but the port does not respond. Even if I use "portc.3" instead for led4, it does not respond.

Thanks for your help

(at 4Mhz, there would be 234375 interrupts per minute, roughly 1500 interrupts per half a second)

ScaleRobotics
- 26th January 2010, 01:02
Somehow, I doubt it is this easy, but... what is the square on BCF IN "square" TCON,2 ???



; Insert interrupt code here
bsf _myflag
movf psave, W
movwf PCLATH
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
bcf IN  TCON,2
bsf INTCON ,7
retfie ; Return from rupt
endasm

matador29b
- 26th January 2010, 01:08
I will have to revise that code, it was written on a PC, and copied to a MAC via USB thumbdrive, something got garbled in the way.
The program was tested in MPLAB, the sequences work as expected, just the ports don't respond, or only some bits respond. It is not an MPLAB issue either, because a programmed chip does the same.
Thanks