2024-06-06 11:08 PM - last edited on 2024-06-07 01:54 AM by Amel NASRI
Hi,
We are using STM32L010C6 Microcontroller, we need to recive the a fixed size of strings (10 charecters ) using interrupted method. But we are not able to receive the charecters completely and its get stuck on the cpltcallback function also. What could be the issue and please gibe me some auggestion to resolve this issue. Iam attaching the main file for the referanc.
2024-06-06 11:38 PM
Hi,
what happens, if there is a spike on the line and receiver sets "error" ? (never cpltcallback ...)
So just how i do: "packet" gets a delimiter (= end of string), receiver is on INT for 1 byte , and also receiver error callback (no better idea...) throw away and set INT for 1 byte again.
So i get the string (of any length (needs buffer of > size and limit , to reset string to zero, if "too long") always, even if there was an error .
Try it this way.
2024-06-07 01:11 PM
But we are not able to receive the charecters completely and its get stuck on the cpltcallback function also.
So what string are you expecting and what does the data buffer show?
If you mean you're stuck in HAL_UART_RxCpltCallback, how do you know you're getting stuck? Are you debugging and the cursor stays where?
2024-06-07 01:23 PM
The function completes immediately, there isn't going to be anything in the buffer.
To use string functions there needs to be a terminal NUL, so 10 characters AND a NUL
Flags set in interrupt/callback context need to be volatile
memset(s,0,10);
printf("haiii\r\n");
HAL_UART_Receive_IT(&husart2, (unsigned char *)s, 10); // << COMPLETES IMMEDIATELY
printf("%s\r\n",s);