Skip to content

Commit 7d302b9

Browse files
committed
canio: mimxrt10xx: Fix CAN frame reception
This code clears the "frame available" flag, which allows the CPU to read and serve the next entry of the Rx FIFO. Without that, the CPU would never advance in the Rx FIFO and will serve the oldest mailbox over and over, until the Rx FIFO overflows.
1 parent 62ea6f9 commit 7d302b9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/mimxrt10xx/common-hal/canio/Listener.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
115115
mp_raise_OSError(MP_EIO);
116116
}
117117

118+
// We've read from the FIFO, clear the "frame available" flag, which
119+
// allows the CPU to serve the next FIFO entry
120+
FLEXCAN_ClearMbStatusFlags(self->can->data->base, (uint32_t)kFLEXCAN_RxFifoFrameAvlFlag);
121+
118122
canio_message_obj_t *message = m_new_obj(canio_message_obj_t);
119123
if (!mimxrt_flexcan_frame_to_canio_message_obj(&rx_frame, message)) {
120124
mp_raise_ValueError(MP_ERROR_TEXT("Unable to receive CAN Message: missing or malformed flexcan frame"));

0 commit comments

Comments
 (0)