Skip to main content

Need help understanding Ultra Low Power Wakeup on PIC16F887

I am trying to implement the "Ultra Low Power Wake Up" feature on a small PIC project. The idea is the chip will go to sleep, and then be woken up in the future by the ULPWU interrupt.

The idea behind the ULPWU is that you connect a capacitor to this pin, charge it and put the chip to sleep. When configured, the ULPWU pin will slowly discharge the capacitor. Once the voltage on the cap falls to some value, the chip wakes up and possibly generates an interrupt.

This application note (PDF) from Microchip explains how the ULPWU is programmed and implemented. See Example 2 and Figure 2 (below).

Example 2:

BANKSEL PORTA           ;
BSF PORTA, 0            ;Set RA0 data latch
BANKSEL ANSEL           ;
BCF ANSEL, 0            ;RA0 to digital I/O
BANKSEL TRISA           ;
BCF TRISA, 0            ;Output high to
CALL CapDelay           ;charge capacitor 
BANKSEL PIR2            ;
BCF PIR2, ULPWUIF       ;Clear flag
BANKSEL PCON            ;
BSF PCON, ULPWUE        ;Enable ULP Wake-up
BSF TRISA,  0           ;RAO to input
BSF PIE2, ULPWUIE       ;Enable interrupt
MOVLW B’11000000’       ;Enable peripheral
                        ;interrupt
MOVWF   INTCON          ;
SLEEP                   ;Wait for interrupt
NOP                     ;

![enter image description here][1]

I have carried this out but am stuck with a strange problem.

When the chip goes to sleep, there is 5V being supplied by the ULWU pin (RA0). If I connect this pin to ground, the chip wakes up and does what it is supposed to do.

My question is, why is there 5V on this pin when it is supposed to be an input? If I have this pin connected to a charged capacitor, the capacitor never discharges (the 5V on the pin is keeping it charged).

Michael
  • 948
  • 1
  • 7
  • 23