2016-09-02 11:13 AM
I am working on STM32F0. I am suing Uart HAL API to send a command to transmit data over UART which is
char *TxBuffer=''ABCD\n\r''; int len = strlen(TxBuffer); HAL_UART_Transmit_IT(&huart,(uint8_t*)TxBuffer,len);However I am unable to send single byte using above Command. If I want to send 'A' , It shows the warning that ''incompatible integer to pointer conversion passing int to parameter type 'uint8_t *'.How can I pass unsigned char values over UART or integer values? I am able to pass string over uart. #stm32 #learn-c #learn-c #cubemx #!stm32 #uart #hal2016-09-02 11:48 AM
This is basic C programming, unrelated to STM32, HAL, etc
Understand types and pointers, passing parameters by value or address. The function wants a pointer/address to the thing it is sending not the thing itself.char c = 'A';
HAL_UART_Transmit_IT(&huart, (uint8_t*)&c, 1);
2016-09-02 01:04 PM
I was little confused with that. Thanks,anyway! I have query, how can I send integer type values over UART using HAL_UART_Transmit_IT?
ifint A =10;How can I transfer value of A over UART?2016-09-02 02:59 PM
int a = 12345;
char str[16];
HAL_UART_Transmit_IT(&huart, (uint8_t*)str, sprintf(str,''%d'',a));
or
itoa(a, str, 10); // Base 10
HAL_UART_Transmit_IT(&huart, (uint8_t*)str, strlen(str));
2016-09-02 03:54 PM
Thanks! It's working fine now.
Can you please have a look at my another discussion topic regarding UART.Here is the link [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/UART%20Receive%20Buffer%20Clear&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=0]UART Receive Buffer