Skip to main content
RKUMA.2
Associate III
August 30, 2021
Solved

how to checksum the ADC data when it is passing to serial monitor of putty through the USB virtual COM port.

  • August 30, 2021
  • 1 reply
  • 1813 views

Hello ,

I am working on the stm32f070c6 controller , i am reading the adc values from controller and passing to the serial monitor of USB virtual COM port, but i want to checksum the values before transmitting the adc values to the serial monitor .how can i do it, if somebody have any idea please give me suggestion to how to checksum the adc values (theory wise I am sure).

Best regards

raj

This topic has been closed for replies.
Best answer by TDK

If your value is uint16_t adc_result, then a checksum could be:

uint16_t adc_result = ...;
uint8_t checksum = adc_result >> 8 + adc_result;

1 reply

TDK
August 30, 2021

Are you asking how to calculate a checksum? Just add the bytes values together, transmit the result along with the original data, and verify it matches on the receiving end. Could also use a CRC to do this which is more complicated but has other advantages.

"If you feel a post has answered your question, please click ""Accept as Solution""."
RKUMA.2
RKUMA.2Author
Associate III
August 30, 2021

Thanks for your reply @TDK​ , theory wise I am sure, but in coding how can add the adc values while transmitting, the adc directly giving an adc in decimal form how can write code for checksum while transmitting I am little bit confused can you please clarify me in the coding part.

Thanks in Advance

raj

TDK
TDKBest answer
August 30, 2021

If your value is uint16_t adc_result, then a checksum could be:

uint16_t adc_result = ...;
uint8_t checksum = adc_result >> 8 + adc_result;

"If you feel a post has answered your question, please click ""Accept as Solution""."