Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 7 months ago.
Printed out string after woken up from deepsleep() are broken.
Hi,
I'm testing deepsleep() function on ST Nucleo-L152RE board. Here is my code.
simple deepsleep and wake up by button
#include "mbed.h" Serial pc(SERIAL_TX, SERIAL_RX); InterruptIn event(USER_BUTTON); DigitalOut myled(LED1); void trigger() { //wait(1); pc.printf("pressed\r\n"); } int main() { int i = 1; pc.baud(9600); pc.printf("Hello World !\r\n"); event.rise(&trigger); while(1) { myled = !myled; pc.printf("Enter deepsleep!\r\n", i++); deepsleep(); pc.printf("Woken up\r\n"); } }
And, here is result.
Result on terminal
Hello World ! Enter deepsleep!............... Woken up Enter deepsleep!
The 'pressed' string in trigger() function is broken. I found an article https://developer.mbed.org/questions/50532/Problems-after-WakeUp-from-deepsleep. So I commented out the printing in trigger().
Then, the result is ...
No printing pressed
Hello World ! Enter deepsleep!C??k??.up Enter deepsleep!
Why is still the string broken?? Does the PLL need some time to be reconfigured? So I added wait(1.0) into trigger().
stuck...
Hello World ! Enter deepsleep!..
Isn't wait() NOP based simple delay()? I don't know why the code stucks.
So I moved wait(1.0) in trigger() to right after deepsleep().
still broken characters
Hello World ! Enter deepsleep!C?Woken up Enter deepsleep!
In this case, the code doesn't stuck. But still broken characters are printed before 'Woken up' string.
Is there anybody know it? Thanks.
-Jongsoo