How can I use STM32 sleep mode with UART

195 views Asked by At

I want to use sleep mode because of the power consumption of the MCU. My aim is basic, but I can not use the process.

I will get data from another MCU via UART. If one of my data is 6, I want to wake-up my MCU and I want to keep it awake. If it is not 6, I want to keep it in sleep mode.

There are two options for me, the first one as I mentioned earlier is UART data, the second one is my ZeroCross interrupt. But both aim is for me. I do not understand how to use it with basic if else conditions.

if (rxdata==6){
//wake-up
}

else if (!rxdata==6){
//sleep-mode
}
1

There are 1 answers

0
0___________ On

I do not understand how to use it with basic if else conditions.

You can't as if you sleep, the core will not be executing any code.

If your UART can detect a particular character, it can invoke the interrupt which will wake the core.