8 years ago.

Why does 9600 baud work but not 300 on F401RE

Hi,

new guy here. I've been messing with the board for the whole day and i just can't get it to report to com at 300 baud. i need it for a university project and the baud must be at 300 ( to be compatible with other equipment).

Okay so: I set the APB prescaler to /8 so that i would be able to go to the low low 300, then i configure USART2 to asynchronus, for 300 baud, 8bits with parity then i leave parity to none ( i actually need odd) because if i do 9600 without parity - it works. if i do it with parity it doesn't. stop bits - 1 data direction - receive and trasmit. oversampling - 16

the code it needs to process is really primitive:

main part

 uint8_t data[20]= "Hello World\n\r";
  while (1)
  {
HAL_UART_Transmit(&huart2, data, 20, 100);
  }

this is the code and the results when set to 300 ( tera is also configured for 300) : http://i.imgur.com/IM80Ims.png

i must be missing something basic, anyone have any idea? i've tried on both IAR and Keil.

Hello Tadas,

Long time ago Eric helped me on this issue. Try following code in main() then set your serial at that low baud rate. Mine was 1200 for a sensor.

// Configure PPRE2 to 42MHz to obtain 1200 KBits for EC sensor serial communication
    RCC->CFGR &= ~0x0000E000;  // PPRE2, Bit 15-13
    RCC->CFGR |=  0x00008000;  // PPRE2: PCLK2 = AHB / 2
    wait_ms(100);
posted by Kamil M 26 Apr 2016
Be the first to answer this question.