9-BIT UART TRANSMISSION STM32 cubemx hal driver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-12-06 9:06 AM
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
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-12-06 1:43 PM
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);
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-12-06 1:43 PM
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);
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-12-07 3:39 AM
Clive,
I test successfully this solution
Thank you for your help.
IBRA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-11 2:36 AM
Hi,
I've tested your solution and it seems to work fine however it is only sending the data at every other request would you know any other way of setting the 9th bit? I've tried changing the variable type to be uint8_t and the data(wrong) is sent at every request.
Kind Regards
Manpreet Singh
