2021-09-24 11:28 PM
Hello,
I working on the stm32f070c6t6 , i want to transmit an adc value to the LabVIEW VISA and storing the adc values in the labview array further processing . but when i continously giving the command from the USB COM port for adc value sometimes it is showing some extra spaces along with after adc value and in the array sometimes the values are coming exactly some times not . so that i am using the checksum code for an adc value i.e uint16_t adc_result =... and I am moving this value into uint8_t data[50] array using sprintf and transmitting the array through usb transmit function but some times the values are correct some times its coming along with spaces (note: every time i am clearing the array [50] using memset function), in order to avoid the spaces i use a checksum code of (from stm32 community group memeber suggestion )
uint16_t result =...;
uint8_t checksum=result >>8 +result;
if (checksum!= (uint8_t )(result>>8+result)){
printf("error while transmitting the data");
//stop usb transmitting function
}
this code also sometimes works properly sometimes not, how can i avoid spaces along with values please if you have an idea give a suggestion.can you please provide the defined c code for checksum.
Best regards
raj
2021-09-25 07:50 AM
There is no need for a checksum "to avoid spaces". And that checksum code has a simple but fatal bug, which I described it your original topic:
Your code shows only one thing - the chosen task is way over your current skill level. Beginners cannot build a space ship, one has to start with the basics. Isn't it obvious? You wanted suggestions... Here they are: