cancel
Showing results for 
Search instead for 
Did you mean: 

9-BIT UART TRANSMISSION STM32 cubemx hal driver

Ibrahim Benaddi
Associate
Posted on December 06, 2017 at 18:06

Hello,

I'm using STM32cubemx and I have created a project using UART in 9-bit configuration. The code is generated and I can find the 'HAL_UART_Transmit' function but the pData parameter is a 8-bit pointer:

HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)

pData should be a 16-bit parameter. I cannot understand how can I send a 9-bit data with this function. Is it a bug in STM32CubeMX?

Thanks

IBRA

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on December 06, 2017 at 22:43

No, the byte array is just a universal solution. A 9-bit value is going to be spread over two bytes, low order bits in the first, or just use a 16-bit array and CAST it. The transfer count is in units, to send two 9-bit words, Size = 2

uint16_t x[2] = (0x123,0x091};

HAL_UART_Transmit(huart, (uint8_t *)x, 2, 1000);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2
Posted on December 06, 2017 at 22:43

No, the byte array is just a universal solution. A 9-bit value is going to be spread over two bytes, low order bits in the first, or just use a 16-bit array and CAST it. The transfer count is in units, to send two 9-bit words, Size = 2

uint16_t x[2] = (0x123,0x091};

HAL_UART_Transmit(huart, (uint8_t *)x, 2, 1000);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 07, 2017 at 11:39

Clive,

I test successfully this solution 

Thank you for your help.

IBRA