-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding HT (half-transfer) callback #6
Comments
Hi there, You are absolutely right, it is strongly advised to utilize and use the half-transfer complete interrupt if the application constantly receives data in a relatively high speed (that the application cannot process in the "worst-case" scheduling scenario). While one "half" is ready to be processed, the other "half" is available for receiving more data while the application is processing the already received data. On a sidenote: this code is originated from a project where raw GPS data needed to be processed. Meaning, in a given period a defined (but not fixed size) data-burst was received in this given period. Furthermore, the application had enough resources and time to safely process all the received data even in the worst-case scheduling scenario. That is the reason why the half-transfer complete event is not implemented in this demonstration. To answer your second question: you need to somehow detect the idle event. This is non-trivial, because you can either receive a bunch of bytes with some delay between the bytes, or you can receive a chunk of data which is entirely continuous (there is zero delay between the bytes). The application cannot know this (and should not!). Of course, you can process an interrupt service routine after each received bytes, however that is exactly the reason why this methos was implemented: to avoid this overhead. Therefore, you need to somehow detect when the Rx line is idle. Some MCU-s, for example the L4-series MCUs from ST have a built-in functionality for exactly this purpose (take a look at the UART RTOR register in the reference manual). However, some MCUs don't have this built-in functionality, meaning the user has to utilize some kind of software-based timer solution. This project is a generic demonstration, this is why this implementation utilizes a software timer-based solution. |
I just saw that your original question was whether you can use the same callback function for the HT complete interrupt. The answer is yes, but you need to implement an additional buffer-handling mechanism to handle the two half-buffers appropriately during processing the data. |
Hi, Thanks for the reply.
Thanks for this great demonstration, it is very helpful, I think ST should add this into their example package. |
Just to add, |
Hello,
I would please like to ask:
Isn't HC (half-transfer complete) actually must be used with circular buffer ? (I see that it is disabled in your example).
I mean, if we have continuous bursts and we process the bytes only when transfer complete (I ignore IDLE for now), it means that during process the start of buffer might get corrupted with new bytes. I think that half transfer should be deal with that.
Another thing, if I may ask, why do you use a software timer after detecting an idle line, instead of calling the uart callback immediately on detection of idle line interrupt ?
Thanks
The text was updated successfully, but these errors were encountered: