What clock does the K64F run at for determining flexcan timing?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What clock does the K64F run at for determining flexcan timing?

Jump to solution
1,009 Views
ironsean
Contributor V

Hello,

 

I'm trying to implement Flexcan on a K64F board with a shield board we've created with a CAN chip on it. I had it working in MQX 4.1.1 with the kflexcan header, but the new peripheral driver seems a lot more barebones. For starters, there's no automated calculation of timing values based on an input baud rate, so I'm trying to figure out how to set it up.

 

There's an example in the TowerK64f board which should be very similar, but I see there it has timings for 48MHz and 60MHz but I don't know what a K64F is running by default.

 

I'm on KDS 3.0 and KSDK 1.2. Not using processor expert of changing the clock timing specifically.

 

Sean

Labels (1)
1 Solution
619 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

Alice is correct that the default clocking of the Kinetis device is using FEI and therefore the core will operate at ~21.9xxxMHz or so.

But if you are running the KDS_3.0.0/KSDK_1.2.0 flexcan demo:

C:\Freescale\KSDK_1.2.0\examples\twrk64f120m\driver_examples\flexcan\flexcan_loopback\kds

Then the clocking code is setting up the core to operate at 120MHz, the peripheral bus at 60MHz, external bus at 30MHz, and flash interface at 20MHz.

This is seen in the board.c BOARD_ClockInit() function that then calls the CLOCK_SYS_SetConfiguration() to set the clocks accordingly.  This function in fsl_clock_MK64F12.c .

If you set into that function call you will see the clock dividers set up as follows:

    /* Set outdiv for safe output clock frequency. */

    CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U);  //DES 0=div by 1, 1=div by 2, 2=div by 3, 4=div by 5

FlexCAN module uses the peripheral bus that is clocked at 60MHz.

Regards,

David

View solution in original post

3 Replies
620 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

Alice is correct that the default clocking of the Kinetis device is using FEI and therefore the core will operate at ~21.9xxxMHz or so.

But if you are running the KDS_3.0.0/KSDK_1.2.0 flexcan demo:

C:\Freescale\KSDK_1.2.0\examples\twrk64f120m\driver_examples\flexcan\flexcan_loopback\kds

Then the clocking code is setting up the core to operate at 120MHz, the peripheral bus at 60MHz, external bus at 30MHz, and flash interface at 20MHz.

This is seen in the board.c BOARD_ClockInit() function that then calls the CLOCK_SYS_SetConfiguration() to set the clocks accordingly.  This function in fsl_clock_MK64F12.c .

If you set into that function call you will see the clock dividers set up as follows:

    /* Set outdiv for safe output clock frequency. */

    CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U);  //DES 0=div by 1, 1=div by 2, 2=div by 3, 4=div by 5

FlexCAN module uses the peripheral bus that is clocked at 60MHz.

Regards,

David

619 Views
ironsean
Contributor V

Thank you, that is fantastic information and helps me understand exactly what I need to know how this is set up, or set it up myself.

I also found that the MQX 4.2 release still has the kflexcan drivers which include auto-calculation of baud rates as an alternate option for anyone searching who finds this.

Sean

0 Kudos
Reply
619 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Sean,

The default mcu clock mode is FEI, you can refer to here(from the K64 reference manual ) :

pastedImage_1.png

And the Flexcan clock , we can refer to here :

pastedImage_0.png

pastedImage_1.png

then , about the "OSCERCLK" and "Bus clock" , please see here :

pastedImage_2.png


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply