2021-08-25 12:11 AM
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.
thanks
2021-08-25 12:15 AM
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))
2021-08-25 12:18 AM
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.
2021-08-25 12:31 AM
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
2021-08-25 01:03 AM
I have tried all configurations matched and mismatched and it still behaves weirdly. any other thing that might cause it?
2021-08-25 01:25 AM
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
2021-08-25 01:35 AM
I'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
2021-08-25 04:36 AM
is that autogenerated with cubemx?
i meant show us where youre handling the RX and TX, also the arduino code
2021-08-25 04:59 AM
I have wrote it myself. here is the arduino and the TX code.
2021-08-25 06:19 AM
whats wrong with USART_SendData()?
also the while(!USART.... (active wait ) should be checked before the transmission attempt not after.