STM32F427 - USART - most significant bits problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-07-16 11:59 PM
Posted on July 17, 2013 at 08:59
Hello,
I'm trying to make a communication protocol via the UART. I have a M4 and an A8 which communicates via RS485 transmitters.For the trials, the UART is set to 9600 bps, 8 bits per character with one stop bit and an even parity, but I regularly get an error at the reception, the most significant bit is forced to one.I checked the frequency, it is of 9615 Hz to the transmition on both microcontrollers. And in the example code I saw that the most significant bit was filtered. (I think it is for reception of a character of the ASCII table)this is the reception in ST's example code : /* Read one byte from the receive data register */ aRxBuffer[uhRxCounter++] = (USART_ReceiveData(EVAL_COM1) & 0x7F);regards, #stm32-usart
Labels:
- Labels:
-
UART-USART
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-07-17 2:50 AM
Posted on July 17, 2013 at 11:50
Is there a pattern to it?
For 8E1 you need to program the USART in 9-bit mode w/parity, to account for the parity bit. From STM32F4-Discovery_FW_v1.1.0\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c- Parity: If the parity is enabled, then the MSB bit of the data written
in the data register is transmitted but is changed by the parity bit.
Depending on the frame length defined by the M bit (8-bits or 9-bits),
the possible USART frame formats are as listed in the following table:
+-------------------------------------------------------------+
| M bit | PCE bit | USART frame |
|---------------------|---------------------------------------|
| 0 | 0 | | SB | 8 bit data | STB | |
|---------|-----------|---------------------------------------|
| 0 | 1 | | SB | 7 bit data | PB | STB | |
|---------|-----------|---------------------------------------|
| 1 | 0 | | SB | 9 bit data | STB | |
|---------|-----------|---------------------------------------|
| 1 | 1 | | SB | 8 bit data | PB | STB | |
+-------------------------------------------------------------+
USART_InitStruct->USART_BaudRate = 9600;
USART_InitStruct->USART_WordLength = USART_WordLength_9b;
USART_InitStruct->USART_StopBits = USART_StopBits_1;
USART_InitStruct->USART_Parity = USART_Parity_Even ;
USART_InitStruct->USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStruct->USART_HardwareFlowControl = USART_HardwareFlowControl_None;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-07-18 4:52 AM
Posted on July 18, 2013 at 13:52
Thanks a lot, it is better.
