CAN FIFO filling faster than flushing
We set up classic CAN on the stm32h747I-DISCO dev board and listen for interrupts on every message:
extern "C" void HAL_FDCAN_RxFifo0Callback(fdcan_handle* hfdcan, std::uint32_t RxFifo0ITs)
{
if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_FULL) != RESET)
{
LOG_ERROR("FIFO0 full\n");
}
if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_MESSAGE_LOST) != RESET)
{
LOG_ERROR("FIFO0 message lost\n");
}
if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != RESET)
{
if (auto* can_reader = can_reader_instance.load(); nullptr != can_reader)
{
can_reader->flush(can::fdcan1);
}
}
}
in flush(), we call HAL_FDCAN_GetRxMessage() over and over to read the FIFO elements into an std::vector and then we print them from the vector. We are anticipating an average message frequency of 1 message per 1ms, but at this speed, we are seeing the FIFO fill up faster than we can read from it. The fastest I have seen a message be handled on our device is around 7ms per message. Should we be able to read the messages fast enough? I have read that DMA is not available for CAN, so are there any other optimizations to be made other than just reading from the FIFO on every message with HAL_FDCAN_GetRxMessage() ?
