Ladies and Gents,
For some reason I keep trying to use smaller PICs instead of larger. My query today is about the Wake-on-pin change feature of the 10F222 and how to implement it.
I've got this program that while sleeping is pulling around 3uA at 6ish volts which is pretty good but I want, well, less. I'm not using a voltage regulator and am feeding 4 x AAA battery voltage to the circuit/PIC. My question is, is this the correct way to implement a wake on pin change? I think this is just a loop that naps alot and that's why it uses so little power not a wake on pin change.
I didn't add a schematic so I hope a word picture will do. The LED cathodes are connected to ground and the anode to a resistor, forget size, and the resistor to PIC port pins. The switch is between the PIC and ground. I know I could get lower current if I used a slower oscillator but that will take up two pins leaving me only 1 output pin. My ultimate goal is to have this battery powered device sit on the shelf for a very long time without having to change the batteries.Code:clear define OSC 4 ' if changed make sure to change config statement adcon0 = 0 ' Turn off ADC option_reg = %01000000 ' 7 = !GPWU wake on pin change. 6 = !GPPU weak pull up status = 0 osccal = %00000000 ' oscillator calibration trisio = %1000 ' All but GP3 is output gpio = 0 #CONFIG __config _IOFSCS_4MHZ & _WDT_ON & _MCLRE_OFF & _CP_OFF #ENDCONFIG GREEN var gpio.1 '-----------------------------variables and constants RED var gpio.0 BLUE var gpio.2 SWITCH VAR GPIO.3 state var byte start_here: ' ------------------------------finally the program state = gpio ' read the gpio ports adcon0 = 0 ' I read somewhere that after a reset you need to set this register again nap 5 if switch = 0 then gosub light_LED ' looking for the button goto start_here light_led: '-----------------------------------------------------led sub red = 1 pause 1000 red = 0 green = 1 pause 1000 green = 0 blue = 1 pause 1000 GREEN = 1 red = 1 pause 1000 GPIO = 0 return END
I'd appreciate some learning if someone would be willing to part with it.




Bookmarks