2013-08-30 05:27 AM
Hi, I have a bit of an issue - I'm trying to put an STM32 into STOP mode, but to have it wake up when a character is sent over the USART (and to receive that character).
My code is just:// .. set up an EXTI for the USART RX pin
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
// disable EXTI for the USART RX pin and swap it back to the USART
RCC_HSEConfig(RCC_HSE_ON);
if
( RCC_WaitForHSEStartUp() == SUCCESS) {
RCC_PLLCmd(ENABLE);
while
(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while
(RCC_GetSYSCLKSource() != 0x08);
}
However the character that is received is corrupted. My guess is that maybe the HSE/PLL takes too long to start up, and so the USART is being clocked too slowly initially.
The serial data is coming in at 9600 baud so I hoped that there would be enough time for everything to get up to speed though. Any ideas? This seems like a common thing to want to do.
#stm32-usart-stop-sleep
2013-08-30 05:27 PM
I think you're going to lose a byte however you attack it. If not the start time of the HSE and PLL, you'd have to be careful about changing the clocking speeds of the USARTx/APBx.
You could try running via HSI (8 or 16 MHz depending on core), or a higher, non-crystal, external source on HSE. The STM32F0 supposedly have a clocking scheme for the USART that wasn't powered down.2013-09-01 03:24 AM
We're using the F207 in our new product and we have to be very sensitive with power consumption, therefore we make use of STOP mode to make the RTOS tickless.
However, we also have a comms channel which we need to monitor and I've recently come up against this very issue. As clive says, I believe it's possible to use the HSI to achieve what you want, but then as he also points out you have to be very careful with clocks, but even the people I've heard who have it ''working'' still have various issues.Our solution? Stick an MSP430 on the board, it acts as a UART buffer. The MSP can be in its low power state and can wake fast enough to not miss a character, then you can use whatever protocol you like to retrieve the data, could be something as simple as IRQ from MSP which wakes the STM which once back up running takes a pin hi/low which then causes the MSP to transmit over another UART to the STM, once empty the IRQ dissapears and the STM removes the signal. We do it a different way, but I'm sure there are hundreds of ways of doing it.Plus having the MSP also allows us to have PWMs running while the main micro is awake.An extra chip, but it solved our issues and the extra power consumption was effectively a shade more than nothing.2013-09-01 06:32 AM
Other methods commonly used to enter/exit low power states with RS232/Serial devices is via CTS/RTS or DSR/DTR and using a handshake protocol to ensure data isn't sent into an abyss.
Changing the clock of the USART mid byte/bit is going to be a hard problem to address.Looked at the ATMEL SAM4L?