Hello,
I would like to put the processor in SLEEP, and to wake up on PIN change.
I defined the pins for interrupt in CNE1 and CNE2 registers.
How to put it to sleep, and how to write the interrupt subroutine?
interrupt OnKeypress(Pic.INT1Interrupt)
IFS1.4 = 0
end interrupt
sub OnStartup() handles Pic.OnStartup
' keypress ISR...
RPINR0 = RPINR0 and &HE0FF ' set RP0 to external interrupt 1 (bits 8..12)
INTCON2 = 0 ' set INT0, INT1, INT2, interupt on falling edge
IFS1.4 = 0 ' reset INT1 interrupt flag
IPC5 = IPC5 and &HFFF8 or 1 ' set low priority
enable(OnKeypress)
' sleep...
low(D11)
asm
pwrsav #0
end asm
end sub
asm
reset
end asm
CNPU1=$0700 'Enable pull-ups
CNPU2=$1604
CNEN1=$0700 'Enable butoons interrupts
CNEN2=$1604
...to wake up on PIN change
If the assigned priority level of the CN interrupt is equal to, or less than, the current CPU priority
level, device execution continues from the instruction immediately following the SLEEP or IDLE
instruction.
If the assigned priority level of the CN interrupt is greater than the current CPU priority level,
device execution continues from the CN interrupt vector address.
interrupt OnInputChange(Pic.CNInterrupt)
' read pins to clear mismatch
' clear intr flag
IFS1.3 = 0
end interrupt
Users browsing this forum: No registered users and 1 guest