2022-03-01 12:15 PM
This is probably a simple question but I can't find a reason for it - Im using the USART on a stm32L412 and I am sending 3 bytes
uint16_t SendDataOn[3]={0x90,0x3C,0x3E};
HAL_UART_Transmit(&huart1,(uint8_t*)SendDataOn,3, 100)
Except when I send this, I get an extra byte between so it means I end up getting 0x90,0x00,0x3C instead of 0x90,0x3c,0x3E. When I increase the number of bytes to send to 5, I get 0x90,0x00,0x3C 0x00,0x3C
how do i set the USART so I don't get the 00 inbetween bytes?
2022-03-01 12:23 PM
> uint16_t SendDataOn[3]={0x90,0x3C,0x3E};
This means, in memory, each value is stored as a halfword, i.e. 2 bytes of which the upper one is 0x00. The transmission function then transmits all that, byte by byte.
JW
2022-03-01 12:27 PM
>>how do i set the USART so I don't get the 00 inbetween bytes?
Use a BYTE array, not a 16-BIT WORD array
2022-03-01 12:35 PM
ah nuts should have known
thanks
2022-03-02 06:36 AM
The HAL library uses uint16_t as the data type when the UART is in 9 bit mode and uint8_t otherwise.