cancel
Showing results for 
Search instead for 
Did you mean: 

Using a defined constant inside HAL_UART_Transmit

skon.1
Senior

Hello,

I'm using STM32 with STM32CubeIDE

This is my code:

#define SOME_DATA 0x01
HAL_UART_Transmit ( & huart6 , SOME_DATA , 1 , 1000 ) ;

The compiler issues the following warning :

passing argument 2 of 'HAL_UART_Transmit' makes pointer from integer without a cast [-Wint-conversion]

What should I do to fix it ?

10 REPLIES 10
Keita
Associate II

you can pass the address directly too like this

uint8_t SOME_DATA = 0x01;
HAL_UART_Transmit ( & huart6 , &SOME_DATA , 1 , 1000 ) ;

Or you can also force it a bit with on the fly casting like this

SOME_DATA = 0x01;
HAL_UART_Transmit ( & huart6 , (uint8_t *)(&SOME_DATA) , 1 , 1000 ) ;