Skip to main content
ABenz.11
Associate II
November 6, 2021
Solved

STM32F4 problem receiving 0xF8 over UART with HAL

Hello I am trying to send hex values over UART with HAL_Transmit

in the cubeIDE I do:

HAL_UART_Transmit(&huart2,(0xF << 4) | (0x8), 1,10);

However I receive in Hterm

0xC5

I cannot make sense over it. Sending text with " some text" works fine

HAL_UART_Transmit(&huart2,"some text", 9,10);

What am I doing wrong??

Thanks and stay healthy

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 6, 2021

It wants to be passed an address/pointer to value, not the value/data directly.

​

ie

uint8_t data = 0xF8;

HAL_UART_Transmit(&huart2,&data, 1,10);

​

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

4 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 6, 2021

It wants to be passed an address/pointer to value, not the value/data directly.

​

ie

uint8_t data = 0xF8;

HAL_UART_Transmit(&huart2,&data, 1,10);

​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ABenz.11
ABenz.11Author
Associate II
November 6, 2021

That works.

So without the & it will send the "address position" of the variable "data" and with the & it will send the "data" @ that position?

Is that correct?

Tesla DeLorean
Guru
November 6, 2021

No the other way round, parameter passed needs to be an address.

​

Y​ou had it sending the byte stored at location 0xF8

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ABenz.11
ABenz.11Author
Associate II
November 6, 2021

Understood.

Thank you.:*

Greetings from Berlin