Hello,
I am trying a simple On Change interrupt on the 16f688. I am setting each pin one by one to be interrupted and move on to the next pin on each interrupt. there is only one little thing wrong with my code.
I will begin on PORTA.0. when an OCI occures the led will blink and will change the IOCA register to PORTA.1
next is the PORTA.1 when an OCI occures the LED will blink and will change the IOCA register to PORTA.2
next is the PORTA.2. (HERE IS MY PROBLEM) when an OCI occures the LED will blink once and then blink again. so next should be PORTA.3 right? wrong the next OIC moves on to PORTA.4 and the code will continue fine from then on until it gets to PORTA.2 again. Here is my code and i'm hoping another pair of eyes can catch my error.
DEFINE OSC 4
TRISA = %111111 'PORTA as input
TRISC = %000000 'PORTC as output
ANSEL = 0
CMCON0 = 7
INTCON.7 = 1 'Global interrupt enabled
INTCON.3 = 1 'PORTA change interupt enabled
OPTION_REG.7 = 0 'Enable Pullup Resistors
'Enable init interupt register
IOCA = 1
on interrupt GOTO myInterrupt
LED VAR PORTC.0
i VAR BYTE
LOW LED
i = 1
main:
HIGH PORTC.1
LOW PORTC.1
goto main
disable
myInterrupt:
i = 2*i
if i = 64 then i = 1
IOCA = i 'alternate the registers
HIGH LED
pause 500
LOW LED
pause 500
INTCON.0 = 0 'remove interrupt flag
resume
Bookmarks