cancel
Showing results for 
Search instead for 
Did you mean: 

Making a UART frame from ADC value WITH ASCII Control Character

jlecl.1
Associate III

Hello,

My aim is to send (from my nucleo board_F103+FTDI) somes ADC value from DMA.

Easy...

But i would like a frame like that (Windows Software need it):

<STX>ADC1;ADC2;ADC3<ETX><CR><LF>

I'm able to send data, no more...

uint16_t sensor_B =1234;
char str[10];
 
sprintf(str, "%u\r\n", sensor_B);
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)str, strlen(str));

Do you know the simplest way to do that ?

1 ACCEPTED SOLUTION

Accepted Solutions

sprintf returns a string length

char str[64];

HAL_UART_Transmit_DMA(&huart1, (uint8_t*)str, sprintf(str, "\x02%u;%u;%u\x03\r\n", sensor_A, sensor_B, sensor_C));

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

View solution in original post

2 REPLIES 2

sprintf returns a string length

char str[64];

HAL_UART_Transmit_DMA(&huart1, (uint8_t*)str, sprintf(str, "\x02%u;%u;%u\x03\r\n", sensor_A, sensor_B, sensor_C));

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

Definitely, you saved my day.

my brain is no longer available...:>