Posted by: Claudio Carbone | 31 October 2011

Put a PIC32 to sleep part2: auto-wake on timed alarm.

Hi Folks!

I’ve been toying around with my little PIC32 and had thoughts about expanding the functionalities.
Since we (now) know how to put the MCU to sleep and how to get out of it, why not teach ourselves how to have it wake up itself at a predetermined time?

Sounds like an alarm!
And yes it is!

So this new demo is just an expansion of the previous: it exploits the RTCC module to have the PIC32 wake up by itself.
The old functionality is still there: you can put it to sleep and bring it online by pressing the button.
But if you don’t wake it up, it will wake itself after 19 seconds.
This number is clearly seen at line 344 of main.c.
Also keep in mind that the number are coded in BCD, so they MUST be fed in hexadecimal.
I’ve been puzzeled for a minute when after asking for a 19 seconds alarm, I got a 13 seconds one!
Then I remembered the BCD thing, and sure enough 19 in dec is 13 in hex.
So keep this in mind.

Not much else to say here, it’s pretty easy really.

Give it a try and let me know.

Last notes (i was forgetting):

a) as before it is configured to run on my Tiertex board, be sure to configure the LEDs and button for your board, and the project for your specific model (mine is a 440F128H).

b) there is a “configureUSB” function in there, this is just to put the USB module to sleep. The module is not used in this project, but another user on the MCHP forum discovered that it doesn’t automatically go to sleep, you have to manually shut it down. The risk is that your MCU will effectively sleep, but will drain 5~10x the power it should while sleeping.
For more details check here.

 

 

oooopsssss, forgot the link!
Download the demo

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: