FlexCAN not working on KV11

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

FlexCAN not working on KV11

1,413 次查看
jacekmey
Contributor I

Hi there,

I have custom board with CAN interface. It's connected to the other CAN device which has been verified to work. Unfortunately Kinetis board dosn'e communicate properly over CAN. I can see that it sends and receives data, but there's no acknowledgement from the other device. This makes Kinetis retransmit continuously. What may be the reason?

Thanks,

Jacek.

0 项奖励
回复
7 回复数

1,130 次查看
egoodii
Senior Contributor III

What is your ultimate CAN clock source?

0 项奖励
回复

1,130 次查看
jacekmey
Contributor I

I have 10MHz crystal connected tp processor, in code I setup pins for crystal and then in code I set up clock:

<p> /* Core clock: 74999040Hz */
 const sim_clock_config_t simConfig = {
        .er32kSrc = 3U,         /* ERCLK32K selection, use LPO. */
        .clkdiv1 = 0x00020000U, /* SIM_CLKDIV1. */
     };
 CLOCK_SetSimSafeDivs();
 BOARD_InitOsc0();
 CLOCK_BootToFeeMode(kMCG_OscselOsc, 3U, kMCG_Dmx32Default, kMCG_DrsMidHigh, CLOCK_SYS_FllStableDelay);
 CLOCK_SetInternalRefClkConfig(kMCG_IrclkEnable, kMCG_IrcSlow, 0);
 CLOCK_SetSimConfig(&simConfig);
 SystemCoreClock = 74999040UL;</p>

And my CAN setup is:

<p>//  Init FlexCAN module.
 flexcanConfig.clkSrc = kFLEXCAN_ClkSrcOsc;
 flexcanConfig.baudRate = 125000U;
 flexcanConfig.maxMbNum = 16;
 flexcanConfig.enableLoopBack = false;
 flexcanConfig.enableSelfWakeup = false;
 flexcanConfig.enableIndividMask = false;
 flexcanConfig.enableDoze = false; //*/
 FLEXCAN_GetDefaultConfig(&flexcanConfig);
 flexcanConfig.clkSrc = kFLEXCAN_ClkSrcPeri;
 flexcanConfig.enableLoopBack = false;
 FLEXCAN_Init(EXAMPLE_CAN, &flexcanConfig, CLOCK_GetFreq(EXAMPLE_CAN_CLKSRC));
 /* Setup Rx Message Buffer. */
 mbConfig.format = kFLEXCAN_FrameFormatExtend;
 mbConfig.type = kFLEXCAN_FrameTypeData;
 mbConfig.id = FLEXCAN_ID_EXT(0x123);
 FLEXCAN_SetRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
 /* Setup Tx Message Buffer. */
 FLEXCAN_SetTxMbConfig(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, true);
 /* Enable Rx Message Buffer interrupt. */
 FLEXCAN_EnableMbInterrupts(EXAMPLE_CAN, 1 << RX_MESSAGE_BUFFER_NUM);
 EnableIRQ(EXAMPLE_FLEXCAN_IRQn);
 /* Prepare Tx Frame for sending. */
 txFrame.format = kFLEXCAN_FrameFormatExtend;
 txFrame.type = kFLEXCAN_FrameTypeData;
 txFrame.id = FLEXCAN_ID_EXT(0x123);
 txFrame.length = 8;
 txFrame.format = kFLEXCAN_FrameFormatExtend;//kFLEXCAN_FrameFormatStandard;
 txFrame.dataWord0 = CAN_WORD0_DATA_BYTE_0(0x11) | CAN_WORD0_DATA_BYTE_1(0x22) | CAN_WORD0_DATA_BYTE_2(0x33) |
                      CAN_WORD0_DATA_BYTE_3(0x44);
 txFrame.dataWord1 = CAN_WORD1_DATA_BYTE_4(0x55) | CAN_WORD1_DATA_BYTE_5(0x66) | CAN_WORD1_DATA_BYTE_6(0x77) |
                      CAN_WORD1_DATA_BYTE_7(0x88);</p>

0 项奖励
回复

1,130 次查看
egoodii
Senior Contributor III

I'm confused about your clock.  You say 10MHz, but it seems like 74.999040MHz comes from 32.768KHz, and that is internal LPO???  LPO is NOT exact enough to hit CAN clocking requirements, AND I'm not sure that 74.999040 can divide 'exactly enough' to 125,000 Hz 'ideal bit clock'.

Can you confirm that the TX bit-timing from this (AND the other bus-members!) is as 'close to 8us as you can measure'?

0 项奖励
回复

1,130 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

I would recommend customer to download KSDK V2.0 software for KV11 product.

And there also with TWR-KV11Z75M sample code package includes FlexCAN example, please download it from here.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,130 次查看
jacekmey
Contributor I

Hi Hui_Ma,

As Earl Goodrich mentioned it's likely that my clock is wrongly configured. My PCB has external 10MHz crystal connected to the MKV11 CPU and external capacitors. As I'm sooo behind the plan, could you give me an example project (using SDK 2.0) how to use external crystal to run CPU (with PLL) at 75MHz?

Thanks,

Jacek.

0 项奖励
回复

1,130 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Please using below code instead of previous BOARD_BootClockRUN() function in <clock_config.c> file:

It will use external 10MHz as FLL reference clock and generate 75MHz core clock with bus clock 25MHz.

void BOARD_BootClockRUN(void)
{
  // Core clock: 75000000Hz
      const sim_clock_config_t simConfig = {
        .er32kSrc = 3U,         /* ERCLK32K selection, use LPO. */
        .clkdiv1 = 0x00020000U, /* SIM_CLKDIV1. */
    };
    CLOCK_SetSimSafeDivs();
    BOARD_InitOsc0();
    
    CLOCK_BootToFeeMode(kMCG_OscselOsc, 3U, kMCG_Dmx32Default, kMCG_DrsMidHigh, CLOCK_SYS_FllStableDelay);
    CLOCK_SetSimConfig(&simConfig);
    
    SystemCoreClock = 75000000U;
 
}


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,130 次查看
jacekmey
Contributor I

I am using KSDK 2.0, this is code from CAN example in it.

0 项奖励
回复