We are running an implementation of an RS485 Slave by using the UART Buffer Model approach and using a callback to handle all buffer handler events through the DRV_USART_BufferEventHandlerSet function.
We are facing a problem when a MASTER sends packets with a correct BAUD Rate but with some instability, enough that can trigger a FRAMING ERROR on the MCU. The USART driver seems to malfunction, ultimately leading to an MCU reset. Note that this issue does not arise if the external device has a wrong BAUD Rate setting, in this case FRAMING errors seem to be handled properly. The issue arises only if the external BAUD Rate is correct but with some instability.
The correct-baud-rate-but-instable condition triggers a FRAMING ERROR and it seems that if we start accumulating bytes on the buffer we may not be able to prevent DRV_USART_BUFFER_EVENT_COMPLETE events from triggering.
Also, the IF function DRV_USART_BufferCompletedBytesGet keeps returning number of bytes > 0, despite the fact that we are calling DRV_USART_ReadQueuePurge and DRV_USART_WriteQueuePurge functions. In some cases it keeps returning this even after physically removing the serial cable, meaning no more packets are coming in.
After capturing a framing error we are calling the following functions:
DRV_USART_ReadQueuePurge( RS485_Data.PortHandler );
DRV_USART_WriteQueuePurge( RS485_Data.PortHandler );
RS485_Data.RxBuffer.Length = 250;
DRV_USART_ReadBufferAdd( RS485_Data.PortHandler, RS485_Data.RxBuffer.Array, RS485_Data.RxBuffer.Length, &RS485_Data.hReadBuffer );
How can we be sure that the buffer complete event will not be triggered after running the purge functions?
mhc_mode: IDE # [IDE|Standalone|Headless]
mhc_version: v3.8.5
mplabx_version: v6.00 # if MPLAB X plugin only
plugin_version: v3.6.4 # if MPLAB X plugin only
compiler: XC32 (4.10)
modules:
- {name: "csp", version: "v3.13.1"}
- {name: "core", version: "v3.11.1"}
- {name: "usb", version: "v3.10.0"}
- {name: "dev_packs", version: "v3.13.1"}
- {name: "littlefs", version: "unknown"}
- {name: "wolfssl", version: "v4.7.0"}
- {name: "net", version: "v3.8.0"}
- {name: "crypto", version: "v3.7.6"}
We are running an implementation of an RS485 Slave by using the UART Buffer Model approach and using a callback to handle all buffer handler events through the
DRV_USART_BufferEventHandlerSetfunction.We are facing a problem when a MASTER sends packets with a correct BAUD Rate but with some instability, enough that can trigger a FRAMING ERROR on the MCU. The USART driver seems to malfunction, ultimately leading to an MCU reset. Note that this issue does not arise if the external device has a wrong BAUD Rate setting, in this case FRAMING errors seem to be handled properly. The issue arises only if the external BAUD Rate is correct but with some instability.
The correct-baud-rate-but-instable condition triggers a FRAMING ERROR and it seems that if we start accumulating bytes on the buffer we may not be able to prevent
DRV_USART_BUFFER_EVENT_COMPLETEevents from triggering.Also, the IF function
DRV_USART_BufferCompletedBytesGetkeeps returning number of bytes > 0, despite the fact that we are callingDRV_USART_ReadQueuePurgeandDRV_USART_WriteQueuePurgefunctions. In some cases it keeps returning this even after physically removing the serial cable, meaning no more packets are coming in.After capturing a framing error we are calling the following functions:
How can we be sure that the buffer complete event will not be triggered after running the purge functions?