cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F107 Uart 5 always sets MSB when sending

thecrocodial
Associate II
Posted on March 11, 2014 at 18:56

Hi everyone,

the title says it all. Scope tells me the timing is fine and the signal looks like it should. Receiving on the other end works. Except the MSB always being set to 1, no matter if I try to send values higher or lower than 127. The debugger confirms that all the settings are fine (USART_CR1 - CR3).  USART_DR is getting the correct value ( In my case 0x10 ). USART_SR shows no errors either. Any advice would be appreciated.

The init looks like this: 

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//GPIOC, UART5_TX

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOC, &GPIO_InitStructure);

//GPIOD, UART5_RX

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOD, &GPIO_InitStructure);

//UART5 -> 2400B, 8-E-1

USART_InitStructure.USART_BaudRate = 2400;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_Parity = USART_Parity_Even;  //USART_Parity_Even;

USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

USART_Init(UART5, &USART_InitStructure); //Init

USART_Cmd(UART5, ENABLE);

#stm32-f107-uart
2 REPLIES 2
Posted on March 11, 2014 at 19:29

Parity is the NINTH bit

USART_InitStructure.USART_WordLength = USART_WordLength_9b;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
thecrocodial
Associate II
Posted on March 12, 2014 at 13:12

*facepalm* thank you :)