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.
6 years, 11 months ago.
Changing baudrate of active UART port.
I have a STM32F746 DISCOVERY board and am trying to figure out how to change the baud rate after being initialized. Unfortunately, after calling the static function RawSerial::baud, the UART port becomes idle and does not transmit the contents of the USART_TDR register.
#include "mbed.h"
RawSerial uartPort(A0, NC);
int main()
{
while (true)
{
uartPort.printf("Transmit at 9600 - default");
wait_ms(1000);
RawSerial::baud(115200);
uartPort.printf("Transmit at 115200");
wait_ms(1000);
RawSerial::baud(9600);
}
}
After running the first baud change, the state of the port goes to idle (logic high) and does not continue. I tried clearing the UE bit in USART_CR1 before changing the baud rate and setting it afterward. The compiler, however, says it does not know the USART_CR1 register. I tried USART4_CR1, USART4->CR1 etc as well.
What am I doing wrong here?
1 Answer
6 years, 11 months ago.
try uartPort.baud(115200); RawSerial::baud(115200) doesn't tell the compiler which uart you want to change the rate of.