cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube FW-F4 V1.21.0 Uart Driver Bug

New.Fish
Associate III

I'm using STM32 Cube FW-F4 V1.21.0 to generate UART driver code, it seem has a bug for:

HAL_UART_Transmit_IT(UART_HandleTypeDef

*huart, uint8_t *pData, uint16_t Size).

The UART will not send the

packet if any data in *pData = 0. 

For example:

HAL_UART_Transmit_IT(&huart3, ModBusBuf, usLength);

 assume usLength = 6;

ModBusBuf point to: 4,6,2,26,1,8; the Uart will send the packet.

                               

 if ModBusBuf point to: 4,6,2,0,1,8; the Uart will not send the

packet. 

Is this bug fixed for newer version? 

5 REPLIES 5
e-zeki
Associate III

*pData = 0 means you're putting 0 in to pointers value which means NULL.

there is NULL check in HAL_UART_Transmit() function. you should use an array or point to adresses not values.

Pavel A.
Evangelist III

> The UART will not send the packet if any data in *pData = 0

Where do you see this? Could you point to this place in source?

https://github.com/pavel-a/stm32f4_libs/blob/c833866661e5a11aed240212e410ca5a1d71a1b8/STM32Cube_FW_F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c#L786

(Note: this repository has several versions up to 1.24, you can navigate among versions via tags in Releases view)

-- pa

@Pavel A.​  https://github.com/pavel-a/stm32f4_libs/blob/c833866661e5a11aed240212e410ca5a1d71a1b8/STM32Cube_FW_F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c#L791

there it is. If you put zero in to *pData it self as a pointing adress it will send error and drop transmission. Other than this there is noway this error would occur.

@New.Fish​ I used this library in maybe 20 different projects and I can assure you it works with every character in ASCII table.

Pavel A.
Evangelist III

Ah, so it is not "*pData = 0". It is pData == NULL.

C is a tough language. Just one small starlet makes a lot of difference ))

-- pa

Learn direct and indirect addressing and the star will make sense.

Java hid it well....