STM32L4.
I'm using UART for time critical communication, where I at a regular interval send three bytes from one controller to another. There is a short pause between every transmission, where the data is being processed, before the next transmission is expected again.
I start the reception like this:
Code: Select all
uartStartReceive(&UARTD4, 3, _rxbuf);
Then I have a receive callback, that processes this data, and then calls that same command again.
This works, mostly. But I also have some noise on my communication line (sometimes NOISE_ERROR gets triggered on the error callback), which I suspect causes my problems. What I'm seeing is that my reception gets unsynchronized.
For example:
I expect: 0xAA 0xBB 0xCC
I get: 0xAA 0xBB 0xAA, then 0xCC 0xAA 0xBB, for example..
It's seems to me like one of the bytes gets missed in one instance, and then I get out of synch, always reading three bytes but from different "packages" or something.
What I want is to receive three consecutive bytes. Is there a way to use the HAL driver to achieve this? Can an error be set by the driver? Or can I check somehow if this was the case?