Yes, but you might want to clear TRIS registers for any pin you want to be an output, and properly setup theIf I wish the pins to be low when the program starts is it ok to use the statement: OPTION_REG=0 : GPIO=0
WDA and WPUDA registers first.
Yes. Bit 7 in OPTION_REG enables or disables internal pull-ups/pull-downs. 1=disabled 0=enabled.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.
The 12F635 has pull-ups or pull-downs. You write to WDA to select pull-ups or pull-downs, and WPUDA to
enable or disable each one indidually.
Secondly,
In the following code
Code: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}Wait for the pin to go low, clear the interrupt flag bit, then SLEEP.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. At what position in the code should
I check to make sure port is LOW before PIC goes to sleep.
If all you need is to wake-up on pin change with low power sleep, I wouldn't use internal pull-ups or pull-downsAs 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.
or the pin-change timed wake-up with ULPWU. If your sensor holds the pin low during idle periods, I would just
let the sensor hold GPIO.1 low with interrupt-on-change enabled only for GPIO.1.




Bookmarks