RT1061 CANFD cannot use IPG clock

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

RT1061 CANFD cannot use IPG clock

Jump to solution
1,768 Views
1318614689
Contributor II

I want to specify the protocol clock of CAN3 as the IPG clock of 150M. I use the mcuxpresso config tool to generate the code and confirm that CAN_CTRL1[CLKSRC] is 1, but CAN3 still uses the clock on CAN_CLK_ROOT. why is that? How can I switch to IPG clock?

Labels (1)
0 Kudos
1 Solution
1,709 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 ,

  Ok, clear now, that's why I suggest you use CSCMR2[CAN_CLK_SEL] select the clock source.

  Wish it helps you!

Best Regards,

Kerry

View solution in original post

0 Kudos
8 Replies
1,699 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 ,

  This one is the clock source selection:

#define FLEXCAN_CLOCK_SOURCE_SELECT (0U)
/* Clock divider for master flexcan clock source */
#define FLEXCAN_CLOCK_SOURCE_DIVIDER (2U)

/*Clock setting for FLEXCAN*/
CLOCK_SetMux(kCLOCK_CanMux, FLEXCAN_CLOCK_SOURCE_SELECT);
CLOCK_SetDiv(kCLOCK_CanDiv, FLEXCAN_CLOCK_SOURCE_DIVIDER);

 

Best Regards,

Kerry

0 Kudos
1,749 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 ,

  Which detail code you are using?

  Please check the RT1060 RM, you can find the CAN3 CTRL1 is no CLKSRC.

 

kerryzhou_0-1642500088387.png

 

Please double check, whether your used bit is correct?

About the clock source, you can check this picture:

kerryzhou_0-1642558975641.png

Use the CCM_CSCMR2[CAN_CLK_SEL] to select source.

kerryzhou_1-1642559022248.png

 

kerryzhou_2-1642559043503.png

 

Best Regards,

Kerry

 

 

0 Kudos
1,740 Views
1318614689
Contributor II

I use these codes to initialize CAN3:

 

const flexcan_config_t CAN3_config = {
.clksrc=kFLEXCAN_ClkSrc0,
.wakeupsrc=kFLEXCAN_WakeupSrcFiltered,
.bitRate = 1000000UL,
.bitRateFD = 7500000UL,
.maxMbNum = 12U,
.enableLoopBack = false,
.enableTimerSync = true,
.enableSelfWakeup = false,
.enableIndividMask = false,
.disableSelfReception = false,
.enableListenOnlyMode = false,
.enableDoze = false,
.timingConfig = {
.preDivider = 5,
.propSeg = 1,
.phaseSeg1 = 1,
.phaseSeg2 = 4,
.rJumpwidth = 2,
.fpreDivider = 0,
.fpropSeg = 1,
.fphaseSeg1 = 2,
.fphaseSeg2 = 2,
.frJumpwidth = 2
}
};
/* Message buffer 0 configuration structure */
const flexcan_rx_mb_config_t CAN3_rx_mb_config_0 = {
.id = FLEXCAN_ID_EXT(134250504UL),
.format = kFLEXCAN_FrameFormatExtend,
.type = kFLEXCAN_FrameTypeData
};
flexcan_handle_t CAN3_handle;

static void CAN3_init(void) {

FLEXCAN_FDInit(CAN3_PERIPHERAL, &CAN3_config, CAN3_CLOCK_SOURCE, kFLEXCAN_64BperMB, true);
/* Message buffer 0 initialization */
FLEXCAN_SetRxMbConfig(CAN3_PERIPHERAL, 0, &CAN3_rx_mb_config_0, true);
/* Message buffer 1 initialization */
FLEXCAN_SetTxMbConfig(CAN3_PERIPHERAL, 1, true);
FLEXCAN_TransferCreateHandle(CAN3_PERIPHERAL, &CAN3_handle, NULL, NULL);
}

 

捕获2.PNG捕获3.PNG捕获4.PNG

If clksrc is kFLEXCAN_ClkSrc1, then CTRL1[CLKSRC] will be 1.

If I set clksrc to kFLEXCAN_ClkSrc1, change CAN3_CLOCK_SOURCE from 60M to 150M, but do not modify the timingConfig, the baud rate observed on the oscilloscope will become 2/5 of the original, which is exactly 60/150. FLEXCAN_FDInit will modify the value of the prescaler according to timingConfig, so I think CAN3 does not successfully switch to the IPG clock source, and FLEXCAN_FDInit sets the prescaler according to the predetermined 150M, which causes the baud rate to drop.

0 Kudos
1,733 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 ,

  Please tell me which detail RT1060 RM version you are using?

  https://www.nxp.com/webapp/Download?colCode=IMXRT1060RM

My RM version is the newest one rev 3, 01/2021.

  So, the clock source should be selected by CSCMR2[CAN_CLK_SEL].

   Please let me know your RM version which CTRL1 bit13 is CLKSRC?

   Seems some bug exists.

Best Regards,

Kerry

0 Kudos
1,728 Views
1318614689
Contributor II

The documentation I am using is Rev. 3, 07/2021。The documentation mentions that the register section of CANFD has been updated.

0 Kudos
1,719 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 

 This is the rev3 07/2021

kerryzhou_0-1642566606955.png

I just download it from the nxp.com, bit 13 still reserved.

Do you download your RM from this link:

https://www.nxp.com/webapp/Download?colCode=IMXRT1060RM

Best Regards,

Kerry

 

0 Kudos
1,714 Views
1318614689
Contributor II

Sorry, I got the documentation version wrong, the version I'm using is 2, 12/2019。I looked at the new version of the docs and it seems that CANFD's ability to use the IPG clock has been removed.

2, 12/2019:

捕获2.PNG

2021:

捕获3.PNGDocumentation I useDocumentation I use

0 Kudos
1,710 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @1318614689 ,

  Ok, clear now, that's why I suggest you use CSCMR2[CAN_CLK_SEL] select the clock source.

  Wish it helps you!

Best Regards,

Kerry

0 Kudos