float and int value TX problem in UART(XMC4500, DAVE4)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User12405
Level 1
Level 1
HI~

I started DAVE4 and XMC4500 to use UART TX and RX
and I checked the format of UART TX , RX function such as
-UART_STATUS_t UART_Transmit(const UART_t *const handle, uint8_t* data_ptr, uint32_t count)
-UART_STATUS_t UART_Receive(const UART_t *const handle, uint8_t* data_ptr, uint32_t count)

I would like to Transmit float and int value(ex: float a=2.3453, int b=23) by UART TX
How do I solve this probl

UART SAMPLE)

#include //Declarations from DAVE Code Generation (includes SFR declaration)

int main(void)
{


float a=2.3453, int b=23; //How do I Transmit float and int variable in UART of DAVE4 ??

uint8_t init_data[] = "Press enter if you want to receive a message";
uint8_t send_data[] = "\nHello world!";
uint8_t read_data = 0x0;

DAVE_Init(); /* Initialization of DAVE APPs */

/* Transmit the introduction message */
UART_Transmit(&UART_0, init_data, sizeof(init_data));

while(1U)
{
/* Read the data */
UART_Receive(&UART_0, &read_data,1);
if(read_data == 0xD)
{
/* Transmit the message */
UART_Transmit(&UART_0, send_data, sizeof(send_data));
read_data = 0x0;
}
}
return 0;
}
0 Likes
1 Reply
Andi_H
Employee
Employee
First solution authored First like received
Hey,

you have to use the "sprintf" function (float, int and so on to string....)

Andi
0 Likes