i.MX 8M Plus Applications Processor Reference Manual
Document Number: IMX8MPRM
Rev. 1, 06/2021
FlexCAN register CTRL1 bit CLKSRC says
0b - The CAN engine clock source is the oscillator clock.
1b - The CAN engine clock source is the peripheral clock.
I have set the FlexCAN peripheral clock root to be 80MHz.
When I set CLKSRC to 1 to use peripheral clock the timing on the CAN bus is incorrect.
However if I set CLKSRC to 0 the timing is correct.
Counting backwards from the actual timings I get, the CANCLK is 80MHz when CLKSRC is 0 and 66.6MHz when CLKSRC is 1.
So neither setting gets me the 24MHz oscillator clock.
What is it that I've missed? I assume I should actually use CLKsrc=0?
Could you tell me which BSP are you using?
How you set the clock source?
This is my code:
flexcan->reg->mcr &= ~MCR_MDIS;
while ((flexcan->reg->mcr & MCR_LPMACK) != 0);
flexcan->reg->mcr = MCR_SOFTRST;
while (flexcan->reg->mcr & MCR_SOFTRST);
/* Module is enabled and in freeze mode */
flexcan->reg->mcr |= MCR_MDIS;
while ((flexcan->reg->mcr & MCR_LPMACK) == 0);
if (cfg->clksrc == 0)
{
flexcan->reg->ctrl1 = 0;
}
else
{
flexcan->reg->ctrl1 = CTRL1_CLKSRC;
}
flexcan->reg->mcr &= ~MCR_MDIS;
while ((flexcan->reg->mcr & MCR_LPMACK) == 0);
Is your CTRL1_CLKsrc=0x00002000?
Have you try the SDK of i.MX8MP? it could download from https://mcuxpresso.nxp.com/en/welcome.
There are examples for flexcan.
SDK_2_14_1_EVK-MIMX8MP\boards\evkmimx8mp\driver_examples\flexcan
I have looked at the MCUXpresso SDK flexcan driver examples and they also use clksrc 0.
My goal is to clarify the reference manual, I would like to find out what clksrc 1 actually is?