Hi,
As I just integrated the usage of the CAN peripheral in a new project using a TM4C1231, I downloaded the latest TivaWare which has a fix for the CANIntClear function and deprecates the ROM version. Basing myself on a few examples (from TivaWare), I came across a situation where I'm not sure if I do things right.
The MCU is configured so that the reception of a message through CAN bus generates an interrupt and this works fine. But all I do in the handler is to raise a flag telling me that I got a reception and use CANIntClear to (obviously) clear the interrupt. But then, when I try to read the message with CANMessageGet, I do not get any data in return because within this function, it checks if the CAN_IF1MCTL_NEWDAT bit equals 1 and it's not, because it's been cleared from the CANIntClear call.
I then tried two things:
1- Fetch the message directly within the interrupt handler before calling CANIntClear. It works but it's not my preferred way to go as I want to spend as less time as possible inside the handler.
2- Revert the fix from tivaware going from this:
HWREG(ui32Base + CAN_O_IF1CMSK) |= CAN_IF1CMSK_CLRINTPND;
to this:
HWREG(ui32Base + CAN_O_IF1CMSK) = CAN_IF1CMSK_CLRINTPND;
and use the bClrPendingInt parameter of the CANMessageGet, to clear the associated interrupt. This works fine.
So, am I missing something or is the fix not adequate in all situations?
Thanks,
J-F