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?
Solved! Go to Solution.
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
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
Hi @1318614689 ,
Which detail code you are using?
Please check the RT1060 RM, you can find the CAN3 CTRL1 is no CLKSRC.
Please double check, whether your used bit is correct?
About the clock source, you can check this picture:
Use the CCM_CSCMR2[CAN_CLK_SEL] to select source.
Best Regards,
Kerry
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);
}
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.
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
The documentation I am using is Rev. 3, 07/2021。The documentation mentions that the register section of CANFD has been updated.
Hi @1318614689
This is the rev3 07/2021
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
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:
2021:
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