Hi,
First off, I apologize for the multiple postings regarding my FlexCAN difficulties, there is another active thread right here: https://community.nxp.com/t5/Kinetis-Microcontrollers/status-is-set-to-kStatus-FLEXCAN-UnHandled-in-... where I have attempted to implement the FlexCAN driver using a callback that gets triggered on reception of data.
I'm trying to read data from a sensor using the FlexCAN module of my MK64F12 Kinetis MCU.
I'm just attempting to get something very simple to work:
/* Initializes the FlexCAN module. */
FLEXCAN_GetDefaultConfig(&flexcanConfig);
FLEXCAN_Init(EXAMPLE_CAN, &flexcanConfig, CLOCK_GetFreq(kCLOCK_BusClk));
flexcanConfig.baudRate = 250000U;
/* Enables the FlexCAN module.*/
FLEXCAN_Enable(EXAMPLE_CAN, true);
/* Sets up the receive message buffer. */
mbConfig.format = kFLEXCAN_FrameFormatExtend;
mbConfig.type = kFLEXCAN_FrameTypeData;
mbConfig.id = FLEXCAN_ID_STD(0x10FF53C2);
FLEXCAN_SetRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
/* Waits until the receive message buffer is full. */
while (!FLEXCAN_GetMbStatusFlags(EXAMPLE_CAN, 1 << RX_MESSAGE_BUFFER_NUM));
/* Reads the received message from the receive message buffer. */
FLEXCAN_ReadRxMb(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &rxFrame);
/* Cleans the receive message buffer full status. */
FLEXCAN_ClearMbStatusFlags(EXAMPLE_CAN, 1 << RX_MESSAGE_BUFFER_NUM);
this never comes out if the while() loop. I can see with a CAN analyzer, that data from 0x10FF53C2 is on the bus. Any idea what could be wrong here? The MCU is running of a 12MHz crystal with the Bus_clock at 60MHz.