6 years, 8 months ago.

Problems after WakeUp from deepsleep


I have attached a simple function to a periodic WakeUp interrupt that prints to the Serial:


When I use sleep it works as expected, but when i use deepsleep, it prints the following line instead:


Why is this?

Question relating to:

Erik - / WakeUp Featured
Wake-up timer library to wake from deepsleep/power-down KL25z, LPC800-MAX, LPC812, powerdown, Sleep, wake-up

1 Answer

6 years, 8 months ago.

It is useful to mention which device you are using.

But I can do a guess: In normal run-mode almost all mbed device use a PLL (or FLL) to increase the crystal/oscillator frequency to a higher frequency. Together with everything else this is disabled in deepsleep. On some devices (most/all LPCs, although that is not according to their user manual, so it depends on the implementation) they automatically start using their PLL again on wake from deepsleep. On the others they switch to their default clock (generally an internal RC oscillator) and you have to set the clock manually to the PLL again.

Now the good news is: You don't have to do this manually: The mbed library does this for you. So directly after the sleep code, there is code to put the clock back to normal. However the interrupt happens before that code can run, which means your printf happens with wrong clock setup.

Solution: Don't use the callback for that, but instead just put it in your user program right after you call deepsleep. Then the clock should be correct again and it should print correctly.

This does all depend a bit on the implementation: The KL25 for example has its Serial which is connected to USBTX/USBRX directly clocked from the crystal, so there your program would work fine. On the other hand the LPC1114 is clocked down by wakeup to something like 10kHz: just running your printf will take ages.

Accepted Answer

Thank you for a describing answer (sorry about no device, I only tagged it; Nucleo L152RE).

I executed the function after the call to deepsleep and it worked fine :)

Just a quick question! do you know if theres something I can do to reduce the powerconsumption in deepsleep?

posted by Håkon Bryn 09 May 2015

I saw your previous question about it, but I don't have it myself. I assume you are measuring it on the normal Nucleo board? One question is if current might be flowing from a high level or pull-up pin into another part.

For sure I would assume it should be able to get much lower, but for my F030 in the past I had a quick look at its consumption and that was also alot higher than it should be. Ideally you have the chip on a seperate board so you can really measure its current, but thats of course not as easy as just doing it on the Nucleo board.

posted by Erik - 10 May 2015

Yes I am measuring on the Nucleo board. If you would like to take a look at my comment to kenjis answer in the following question and maybe u have some input. I am sorry if this is very wrong, i am kinda deeper than my knowledge goes :P


posted by Håkon Bryn 10 May 2015