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.
8 years, 6 months ago.
Parity is not enabled
#include "mbed.h"
Serial uart(PA_9, PA_10);
int main()
{
uart.baud(9600);
uart.format(8, Serial::Even, 1);
for (;;)
{
uart.puts("ABC");
wait_ms(200);
}
}
Question relating to:
1 Answer
8 years, 6 months ago.
Ok - the corrected code works but the right answer is posted here (see Jan's comments):
https://community.st.com/thread/39105-st32f302rc-usart-with-parity-not-working
#include "mbed.h"
Serial uart(PA_9, PA_10);
int main()
{
uart.baud(9600);
uart.format(8, uart::Even, 1); // see below
for (;;)
{
uart.puts("ABC");
wait_ms(200);
}
}
See page 1308
E81 format = 8 bits (total) so 7 bits for DATA; Even parity = 8th bit; 1 stop bit. So use 7 Bit; Even Parity; 1 Stop bit in Teraterm to see "ABC"
To use 8 bits of data; Even parity; 1 stop bit -> you must use 9 bit mode for formatting
Really learned something new here about the STM USART - thanks for your question !!
Maybe... NOT change M bits when parity enable. Look at Table 237 on RM0351 reference manual.
posted by Takashi Matsuoka 17 May 2017