cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 UART1 most significant part problem

EPora.1
Associate II

Hi,

I'm trying to use uart1 in stm32f411ce and I have a weird problem. in my test I am sending data from the stm32 to an arduino and printing the received data on the serial monitor. In the stm32 I'm sending bytes with the most significant part counting from 0x02 to 0xF2. the list significant part always transmits well but the LSP has a weird behavior. I made a table that shows the transmitted bytes and the received bytes.

thanks0693W00000DqIsqQAF.jpg

13 REPLIES 13
Javier1
Principal

What is your uart configuration?, maybe youre not matching what your arduino is expecting?

(normally (Data length =8, Parity bit =1, Number of Stop Bits=None))

we dont need to firmware by ourselves, lets talk

Thanks for your answer!

my configuration is (Data length =8, Parity bit =0, Stop bits =1). I thought that that is the default. I'll test the configuration you wrote.

You can also change it in your arduino, https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/

Serial.begin(115200, SERIAL_8N1);
/*
SERIAL_5N1
SERIAL_6N1
SERIAL_7N1
SERIAL_8N1 (the default)
SERIAL_5N2
SERIAL_6N2
SERIAL_7N2
SERIAL_8N2
SERIAL_5E1: even parity
SERIAL_6E1
SERIAL_7E1
SERIAL_8E1
SERIAL_5E2
SERIAL_6E2
SERIAL_7E2
SERIAL_8E2
SERIAL_5O1: odd parity
SERIAL_6O1
SERIAL_7O1
SERIAL_8O1
SERIAL_5O2
SERIAL_6O2
SERIAL_7O2
SERIAL_8O2
*/

*You might be right (Data length =8, Parity bit =0, Stop bits =1) is the default, just try out things

we dont need to firmware by ourselves, lets talk

I have tried all configurations matched and mismatched and it still behaves weirdly. any other thing that might cause it?

what about, clock missmatch? (are you using your own custom stm32 board?

Or you could be messing up with the variable type castings, are you using pointers?

Are you receiving and replying with the same variable type?

Maybe you can show us some code

we dont need to firmware by ourselves, lets talk

0693W00000DqJStQAN.jpg0693W00000DqJSjQAN.jpgI'm using a custom board with an 8mhz crystal clocked to 96mhz. the usart1 bus runs on 48mhz. this is the uart and clock configuration code

is that autogenerated with cubemx?

i meant show us where youre handling the RX and TX, also the arduino code

we dont need to firmware by ourselves, lets talk
EPora.1
Associate II

I have wrote it myself. here is the arduino and the TX code.0693W00000DqLOPQA3.jpg0693W00000DqLOKQA3.jpg0693W00000DqLNlQAN.jpg

whats wrong with USART_SendData()?

also the while(!USART.... (active wait ) should be checked before the transmission attempt not after.

we dont need to firmware by ourselves, lets talk