Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

[WICED-SDK-2.2.1]

When I use even parity like below, USART doesnt work properly with WICED SDK 2.2.1.

---

uart_config = {

    .baud_rate    = 115200,

    .data_width   = DATA_WIDTH_8BIT,

    .parity       = EVEN_PARITY,

    .stop_bits    = STOP_BITS_1,

    .flow_control = FLOW_CONTROL_CTS_RTS, };

---

In stm32fXxx_platform.c, DMA is configured as following around line.1099.

---

if ( config->data_width == DATA_WIDTH_9BIT ) {

    dma_init_structure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;

    dma_init_structure.DMA_MemoryDataSize     = DMA_MemoryDataSize_HalfWord;

}

else

{

    dma_init_structure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;

    dma_init_structure.DMA_MemoryDataSize     = DMA_MemoryDataSize_Byte;

}

---

It should be fixed as below I think.

---

if ( config->data_width == DATA_WIDTH_9BIT ) && ( config->parity == NO_PARITY ) ...

---

Could you check this and give me your feedback?

0 Likes
1 Solution
Anonymous
Not applicable
You are correct, this is an issue with SDK-2.2.1 and previous releases.

STM32 assumes data includes the (optional) parity bit.

We say, data is data, and WICED does not assume the (optional) parity bit is part of the data.

To fix this, please patch <WICED-SDK-2.2.1>/Wiced/Platform/common/ARM_Cortex_M3/STM32F2xx/stm32f2xx_platform.c (and STM32F1xx, F4xx) as follows around line 1036:

--------------------------------------------------------------------------------------------------------------------------------------------

     usart_init_structure.USART_Mode       = 0;

     usart_init_structure.USART_BaudRate   = config->baud_rate;

-    usart_init_structure.USART_WordLength = ( config->data_width == DATA_WIDTH_8BIT ) ? USART_WordLength_8b : USART_WordLength_9b;

+    usart_init_structure.USART_WordLength = ( (config->data_width == DATA_WIDTH_9BIT) ||

+                                              ( (config->data_width ==  DATA_WIDTH_8BIT) && (config->parity != NO_PARITY) )

+                                            ) ?  USART_WordLength_9b : USART_WordLength_8b;

     usart_init_structure.USART_StopBits   = ( config->stop_bits == STOP_BITS_1 ) ? USART_StopBits_1 : USART_StopBits_2;

     switch ( config->parity )

--------------------------------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Likes
1 Reply
Anonymous
Not applicable
You are correct, this is an issue with SDK-2.2.1 and previous releases.

STM32 assumes data includes the (optional) parity bit.

We say, data is data, and WICED does not assume the (optional) parity bit is part of the data.

To fix this, please patch <WICED-SDK-2.2.1>/Wiced/Platform/common/ARM_Cortex_M3/STM32F2xx/stm32f2xx_platform.c (and STM32F1xx, F4xx) as follows around line 1036:

--------------------------------------------------------------------------------------------------------------------------------------------

     usart_init_structure.USART_Mode       = 0;

     usart_init_structure.USART_BaudRate   = config->baud_rate;

-    usart_init_structure.USART_WordLength = ( config->data_width == DATA_WIDTH_8BIT ) ? USART_WordLength_8b : USART_WordLength_9b;

+    usart_init_structure.USART_WordLength = ( (config->data_width == DATA_WIDTH_9BIT) ||

+                                              ( (config->data_width ==  DATA_WIDTH_8BIT) && (config->parity != NO_PARITY) )

+                                            ) ?  USART_WordLength_9b : USART_WordLength_8b;

     usart_init_structure.USART_StopBits   = ( config->stop_bits == STOP_BITS_1 ) ? USART_StopBits_1 : USART_StopBits_2;

     switch ( config->parity )

--------------------------------------------------------------------------------------------------------------------------------------------
0 Likes