Unable to retrieve data through FlexCAN module

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Unable to retrieve data through FlexCAN module

799 次查看
stdcerr
Contributor IV

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.

标签 (1)
0 项奖励
2 回复数

787 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

 

Just to confirm, are you using a CAN Transceiver for the bus? From the previous post, you said that the loopback worked fine so the example is well configured.

 

I'm waiting for your reply.

Best regards,

Omar

0 项奖励

781 次查看
stdcerr
Contributor IV

Yes, a CAN transceiver is used. I did probe on the pins of the MCU and confirmed, that the CAN Rx signals do make it through to the MCU. As for the loopback example, it doesn't actually use any physical lines, it's just an "internal" loopback.

0 项奖励