My problem is that I sometimes looses a byte. Not many, but maybe 1 out of
10.000.
The ISR receives EVERY bytes sent to it.
But when reading the queue, some bytes are missing.
By mistake, I used the NON-ISR xQueueSendToBack in the first version.
When using this, I never lost any bytes, but entered HardfaultHandler once
in a while.
Anyone knows why I loose bytes between xQueueSend and xQueueReceive?
Do you check the return value of xQueueSendToBackFromISR()? If it returns pdFALSE then the queue was full.
Also, do you call portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) (or portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ) - depending on the port) at the end of your interrupt handler. If not then adding it may allow the receiving task to drain the queue sooner.
Generally it is not recommended to use a queue to send every received byte unless the data is very slow (like typed characters from a keyboard, as an example). It will be more efficient to store received bytes in a RAM buffer, then use a semaphore (or task notification in V8.2.0) to unblock a task when there is a whole message that needs processing.
I send 35 characters every second, so the data amount is very small.
It is not typed, but, still, i should be able to handle them
My interrupt never misses a character, and my queue is never full (set to 100 bytes length). When I check the queue free size, there are never more than 5 characters in the queue.
I know it is not the most efficient way to do it, but it should be OK with this amount of data.
portYIELD_FROM_ISR and portEND_SWITCHING_ISR are not available.
Only portYIELD is.
portEND_SWITCHING_ISR() is not available. Should I include something, or enable something in the config file?
I can’t find anything in the reference manual.