Skip to main content
jlecl.1
Associate III
May 30, 2023
Solved

Making a UART frame from ADC value WITH ASCII Control Character

  • May 30, 2023
  • 1 reply
  • 1033 views

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 ?

This topic has been closed for replies.
Best answer by Tesla DeLorean

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));

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
May 30, 2023

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 VenmoUp vote any posts that you find helpful, it shows what's working..
jlecl.1
jlecl.1Author
Associate III
May 30, 2023

Definitely, you saved my day.

my brain is no longer available...:>