hevans1944
Hop - AC8NS
No, but I'm not looking for the shortest interval available. The 135 ms interval is with the WDT prescaler set to 1:8 division ratio. I believe it will go down to about 18 ms with 1:1 division ratio, but 135 ms is as close as I can get to the 100 ms originally desired. Even longer periods would be better, except I have to examine the push-button switch to see if the flashlight LED should be on or not after each WDT timeout.Is that the shortest interval available?
I would also like to detect if the button is pressed or released between WDT timeouts. For example, if a sustained push-button press for more than 0.5 seconds places the flashlight in Sustained ON mode, then I need to (1) monitor the switch to determine that it has been released and (2) turn off the flashlight if the switch is pressed again. Clearly, I can't have the pressed switch drawing current from the energy storage capacitor while the flashlight is on. So it needs to be enabled with a pull-up resistor connected to an output port set high, the switch state read quickly from an input port, and then the pull-up disabled by setting its output port low again to minimize the current burden while the flashlight is on and the PIC is asleep. This is the 15 μs interval I mentioned above.
If I turn on the switch pull-up and read that the switch is actuated (grounded), there is no need to do so again until the switch is de-actuated. Problem is, I can't tell that this has occurred without applying power to the pull-up again. So, as a compromise, I only enable the pull-up when the PIC resets from a WDT timeout, meaning I can only read the switch state once every 135 ms. That seems adequate to me from a human-machine-interface (HMI) perspective.
I don't know yet what the delay is between reset and turning off the MOSFET, but it needs to be as short as possible, a few microseconds. Since TRIS and OPTION reset to all ones on reset, the MOSFET gate will hold a charge and remain on until (1) the output port controlling the MOSFET is set low and (2) a TRIS bit is set low to enable the output port controlling the MOSFET gate. I could do this "up front" at ORG 0x00 before doing anything else, except I need to preserve the accumulator register for the OSCCAL content loaded at 0x1f (for the PIC10F200) or 0x1ff (for the PIC10F206) by the MOVLW kk instruction there. Not a biggie, and OSCCAL register only needs to be loaded once at POR, but every instruction after ORG 0x00 is one more microsecond down the road sucking power from the energy storage capacitor until the MOSFET is gated off.