I am working on a board that uses an STM32F411 connected to a bluetooth module over USART. One of the goals is to enable Low-power consumption in STOP mode.
A brief summary of the platform:
- The Bluetooth module can wake up the STM32 using an EXTI interrupt when it has data to send.
- I have an interrupt handler to handle the interrupt in (1).
- The STM32 enters stop mode in the RTOS's idle thread once it detects that no threads are interested in keeping the MCU awake.
I am able to get the processor into Low Power STOP mode. However, when the Bluetooth module wakes up the MCU to commence data transfer, the MCU picks up junk data over the USART.
I have tried using the alternate function of the USART RTS gpio - I set it high so that the bluetooth module cannot send any data over the USART until I am ready. In my ISR, on receiving the Bluetooth interrupt, I signal a thread to re-initialize the USART at the same rate that it was receiving data at, prior to STOP mode.
I am not sure why the USART is behaving in this manner. As per the documentation, the configuration in STOP mode is required to be preserved across the low power mode.
I would appreciate some pointers for debugging this issue. Thank you in advance.
Please let me know if you need any more information.
EDIT: Found out the cause of the issue. When the processor wakes up, the uart has already transferred/lost some data; because of this, the handler for the data gets corrupted bytes. The solution that I finally used involved setting the RTS to HIGH prior to sleep; when the processor wakes and is ready to accept data, it pulls the RTS low and reconfigures the pin as a UART pin. This fixes the issue.
Thanks for your suggestions.