Hi, I may be too late to ask this as this thread is few years old, but I will take my chances.
I am trying to understand internal pull up on/off along with making sure pins are low before going to sleep.
If I wish the pins to be low when the program starts is it ok to use the statement: OPTION_REG=0 : GPIO=0
Since I am trying to understand internal pull up on/off so I will ask if there is any significance of OPTION_REG=128 over what I wrote above.
Secondly,
In the following code
Suppose my port (Lets say sensor attached to GPIO.1) is held low and I want PIC to wake up once it goes high, does what its suppose to do, and when it again goes low PIC goes to sleep.Code:Main: GPIO.0 = 1 ' set data latch on GPIO.0 TRISIO.0 = 0 ' GPIO.0 = output (charging cap) PAUSEUS 24 ' charge cap for 24uS TRISIO.0 = 1 ' GPIO.0 = input to discharge cap IOCA.0 = 1 ' int on change enabled for GPIO.0 INTCON = %00001000 ' global ints disabled, int on change enabled @ SLEEP ' put PIC to sleep TOGGLE PROBE ' indicate ULPWU wake up from sleep & clear mismatch INTCON.0 = 0 ' clear wake up on change int flag GOSUB TestVolts ' go test for under voltage condition GOTO Main ' not sure what this does...;o}
At what position in the code should I check to make sure port is LOW before PIC goes to sleep.
As lets say I put "WHILE gpio.1:wend" before capacitor is charged in the main loop, I fear that port could go high again while capacitor is getting charged and pic will go to sleep with the port being high.
If I put it after the capacitor charge statement, I fear the capacitor getting discharged while waiting for the port to go low which may take 1-2 seconds.
Hope I can have some help over the two issues. Thanks a lot




Bookmarks