Ultra Low Power Wakeup Timer (Ulpwu)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Beertree
Posts: 24
Joined: Wed Apr 29, 2015 4:49 pm
Has thanked: 5 times
Been thanked: 5 times
Contact:

Ultra Low Power Wakeup Timer (Ulpwu)

Post by Beertree »

Good day,
I ve got problems initialzing the ulpwu/current sink on a PIC16F687 chip. Especially the interrupts are not waking up the device in sleep mode. Isnt the set_bit and the clear_bit function working in Flowcode or is my syntax wrong? What I want to do is

a) Charge the capacitor on RA0 by configuring the
RA0 pin to output (= 1).
b) Configure RA0 as an input.
c) Enable interrupt-on-change for RA0.
d) Set the ULPWUE bit of the PCON register to
begin the capacitor discharge.
e) Execute a SLEEP instruction.

The capacitor is charged only once instead of routinely...
can somebody help, please?

Regards
Attachments
fcf20160502.fcfx
(4.49 KiB) Downloaded 266 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Ultra Low Power Wakeup Timer (Ulpwu)

Post by Benj »

Hello,

You might need to read the porta register before issuing the sleep command to latch in the initial interrupt on change state.

Add this to the end of your ulpwu C icon and see if it helps.

FCV_X = porta;

Beertree
Posts: 24
Joined: Wed Apr 29, 2015 4:49 pm
Has thanked: 5 times
Been thanked: 5 times
Contact:

Re: Ultra Low Power Wakeup Timer (Ulpwu)

Post by Beertree »

Hello again and thank you for the reply,
I added a latch command in the program but there is still no progress. On the scope I can see that the capacitor is charging and discharging (yellow) but the pic still doesn't wake up once in sleep.
I orientated on the ASM given in the datasheet:
BCF STATUS,RP0 ;Bank 0
BCF STATUS,RP1 ;
BSF PORTA,0 ;Set RA0 data latch
BSF STATUS,RP1 ;Bank 2
BCF ANSEL,0 ;RA0 to digital I/O
BSF STATUS,RP0 ;Bank 1
BCF STATUS,RP1 ;
BCF TRISA,0 ;Output high to
CALL CapDelay ;charge capacitor
BSF PCON,ULPWUE ;Enable ULP Wake-up
BSF IOCA,0 ;Select RA0 IOC
BSF TRISA,0 ;RA0 to input
MOVLW B’10001000’ ;Enable interrupt
MOVWF INTCON ;and clear flag
BCF STATUS,RP0 ;Bank 0
SLEEP ;Wait for IOC

Did I translate it right?

regards
Attachments
DS1Z_QuickPrint1.png
Scope connected via 1Meg resistor
(36.06 KiB) Downloaded 2541 times
20160508_oel.fcfx
Flowcode file
(4.45 KiB) Downloaded 264 times

Beertree
Posts: 24
Joined: Wed Apr 29, 2015 4:49 pm
Has thanked: 5 times
Been thanked: 5 times
Contact:

Re: Ultra Low Power Wakeup Timer (Ulpwu)

Post by Beertree »

Hello again,
After further Investigations and a lot of disappointing tries with no progress I think I need to ask the question a bit more precisely.

I want to use the low power timing module of the PIC, which is a very useful function to save energy and wake up the PIC in more or less precise intervals. All you need, is to connect a small capacitor, charge it and send the pic to sleep. When the voltage of the capacitor falls below a certain level after a few seconds/minutes/hours the PIC awakes again. My programm charges the capacitor and sends it to sleepmode but then it doesn't want to wake up again.
What I did was to take the example asm code from the datasheet and tried to translate it into c. Perhaps someone can just tell me, where my failure is?

BCF STATUS,RP0 ;Bank 0 --->* That I did not translate, because the compiler should switch the banks itself, right?
BCF STATUS,RP1 ; ----> dito
BSF PORTA,0 ;Set RA0 data latch ---->set_bit (porta,0);
BSF STATUS,RP1 ;Bank 2 ---> like *
BCF ANSEL,0 ;RA0 to digital I/O -----> clear_bit (ansel,0);
BSF STATUS,RP0 ;Bank 1 ----->*
BCF STATUS,RP1 ; ------>*
BCF TRISA,0 ;Output high to ------>clear_bit (trisa,0);
CALL CapDelay ;charge capacitor ----->FCI_DELAYBYTE_MS(1);
BSF PCON,ULPWUE ;Enable ULP Wake-up ----->set_bit (pcon, 5); or ------->set_bit (pcon, ULPWE); (both does not fuktion)
BSF IOCA,0 ;Select RA0 IOC ---->set_bit (ioca,0);
BSF TRISA,0 ;RA0 to input ---->set_bit (trisa,0);
MOVLW B’10001000’ ;Enable interrupt ------>intcon=0b10001000;
MOVWF INTCON ;and clear flag ----->dito
BCF STATUS,RP0 ;Bank 0 ----->*
SLEEP ;Wait for IOC ----->sleep();

I don't get any warnings from BoostC, the Pic just goes to sleep and does not wake up again, when the timing capacitor discharges.
Who can help or tell me me, what to do next to find the mistake?

kind regards

Post Reply