Bruce's program is very well documented, it would be good to know I'm reading how to put the PIC to sleep and wake on interrupt. Am I on the right lines here?
Setting INTCON REG bit 3 to 1 enables the GPIO port change interrupt, the interupt flag is set on INTCON REG bit 0. (I'm thinking bit.0 is now logic 1 until cleared.)Code:INTCON = %00001000 ' Enable port change wakeup from sleep
Setting the IOC pins 3 / 4 (button presses) to logic 1 (goes low when button pressed).Code:IOC = %00011000 ' Wakeup on change enabled for GPIO.3,4
So if no button is pressed:Code:Main: ' Read port to clear missmatch, if with no buttons pressed, then ' clear int-on-change flag & snooze until wake up on change. This ' conserves battery power on the demo board with 3V coin cell. IF (GPIO.3=1) AND (GPIO.4=1) THEN ' pins will be 0 only when buttons are pressed E_OUT=0 ' Disable transmitter INTCON.0 = 0 ' No buttons down, so clear int on change flag @ SLEEP ' and start snoozin..zzzzzzzzzzz @ NOP ' Do nothing for 1st instruction on wake-up ENDIF E_OUT=1 ' Enable transmitter (+ lights RFEN LED on demo board) PAUSEUS 25 ' Allow RF stage to stabilize
1/ GPIO.3 / 4 stay high
2/ E_OUT=0 the transmitter (SYMBOL E_OUT = GPIO.5 ' RF transmitter enable output) stays off.
3/ INTCON.0 = 1 changes to INTCON.0 = 0 (software reset)
4/ @ SLEEP (The PIC goes to sleep, no time value set).
5/ @ NOP (I'll take as per NOP above, I couldn't find anything on this in the manual).
If buttons on GPIO.3/4 are pressed then the program continues....... As I will tomorrow.
How does this look?
Dave




Bookmarks