CAN_DeInit API Error

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

CAN_DeInit API Error

跳至解决方案
1,192 次查看
Embedded_novice
Contributor III

HI.

I attempted to shut down the CAN controller before the BOOTLOADER jumped to the APP, but when I called CAN_DeInit, it actually wasn't re-initialized, resulting in incorrect frames being sent on the CAN bus after the jump. I would like to know if there are any problems with this logical judgment. I have set CtrlState to TRUE, but the reverse initialization requires it to be FALSE in order to execute.CAN_DeInit.png

0 项奖励
回复
1 解答
1,112 次查看
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Embedded_novice

1. The controller modes are defined in the AUTOSAR specification, thus described in the FlexCAN MCAL driver user manual found under the following path: "C:\NXP\S32DS.3.X.X\S32DS\software\PlatformSDK_S32K3\RTD\Can_43_FLEXCAN\doc\RTD_CAN_43_FLEXCAN_UM.pdf"

Snag_a0158d5.png

2. By AUTOSAR standards, yes, it is mandatory. The processing logic depends on the driver implementation. For example, in the FlexCAN driver, functions called are FlexCAN_Ip_SetStartMode() and FlexCAN_Ip_SetStopMode(), both of which enable and disable the module, respectively.

AUTOSAR specification also provides a transition diagram in their CAN specification document:

Snag_a0e08b2.png

Best regards,
Julián

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,156 次查看
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Embedded_novice,

Before calling CAN_DeInit, set all controllers to STOPPED to allow it to de-init properly:

/* Stop Can controller */
Can_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_0, CAN_CS_STOPPED);

/* De-Initialize Can driver */
Can_43_FLEXCAN_DeInit();

Best regards,
Julián

0 项奖励
回复
1,132 次查看
Embedded_novice
Contributor III

Hi.

I understand your train of thought now. I would like to know if this state transition diagram is correct. Additionally, I have two more questions:
1. Where can I find this state transition in the manual of the MCU? I didn't see any similar state description in the RM.
2. Is this state transition mandatory? Is the same processing logic applied in other MCU architectures?
Thank you very much for your help!ModeSwitch.png

0 项奖励
回复
1,113 次查看
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Embedded_novice

1. The controller modes are defined in the AUTOSAR specification, thus described in the FlexCAN MCAL driver user manual found under the following path: "C:\NXP\S32DS.3.X.X\S32DS\software\PlatformSDK_S32K3\RTD\Can_43_FLEXCAN\doc\RTD_CAN_43_FLEXCAN_UM.pdf"

Snag_a0158d5.png

2. By AUTOSAR standards, yes, it is mandatory. The processing logic depends on the driver implementation. For example, in the FlexCAN driver, functions called are FlexCAN_Ip_SetStartMode() and FlexCAN_Ip_SetStopMode(), both of which enable and disable the module, respectively.

AUTOSAR specification also provides a transition diagram in their CAN specification document:

Snag_a0e08b2.png

Best regards,
Julián

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2189148%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ECAN_DeInit%20API%20%E9%94%99%E8%AF%AF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2189148%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%E3%80%82%3C%2FP%3E%3CP%3E%E5%9C%A8%20BOOTLOADER%20%E8%B7%B3%E8%BD%AC%E5%88%B0%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E4%B9%8B%E5%89%8D%EF%BC%8C%E6%88%91%E6%9B%BE%E5%B0%9D%E8%AF%95%E5%85%B3%E9%97%AD%20CAN%20%E6%8E%A7%E5%88%B6%E5%99%A8%EF%BC%8C%E4%BD%86%E6%98%AF%E5%BD%93%E6%88%91%E8%B0%83%E7%94%A8%20CAN_deinit%20%E6%97%B6%EF%BC%8C%E5%AE%83%E5%AE%9E%E9%99%85%E4%B8%8A%E6%B2%A1%E6%9C%89%E8%A2%AB%E9%87%8D%E6%96%B0%E5%88%9D%E5%A7%8B%E5%8C%96%EF%BC%8C%E5%AF%BC%E8%87%B4%E8%B7%B3%E8%BD%AC%E5%90%8E%E5%9C%A8%20CAN%20%E6%80%BB%E7%BA%BF%E4%B8%8A%E5%8F%91%E9%80%81%E9%94%99%E8%AF%AF%E7%9A%84%E5%B8%A7%E3%80%82%E6%88%91%E6%83%B3%E7%9F%A5%E9%81%93%E8%BF%99%E4%B8%AA%E9%80%BB%E8%BE%91%E5%88%A4%E6%96%AD%E6%98%AF%E5%90%A6%E6%9C%89%E9%97%AE%E9%A2%98%E3%80%82%E6%88%91%E5%B7%B2%E5%B0%86%20CtrlState%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%20%22true%22%EF%BC%8C%E4%BD%86%E5%8F%8D%E5%90%91%E5%88%9D%E5%A7%8B%E5%8C%96%E9%9C%80%E8%A6%81%E5%AE%83%E4%B8%BA%20%22false%20%22%E6%89%8D%E8%83%BD%E6%89%A7%E8%A1%8C%E3%80%82%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CAN_DeInit.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22CAN_DeInit.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361650i4E55AA0680B38758%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CAN_DeInit.png%22%20alt%3D%22CAN_DeInit.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2190903%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAN_DeInit%20API%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2190903%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F213197%22%20target%3D%22_blank%22%3E%40%E5%B5%8C%E5%85%A5%E5%BC%8F%E6%96%B0%E6%89%8B%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E1.%E6%8E%A7%E5%88%B6%E5%99%A8%E6%A8%A1%E5%BC%8F%E5%9C%A8%20AUTOSAR%20%E8%A7%84%E8%8C%83%E4%B8%AD%E8%BF%9B%E8%A1%8C%E4%BA%86%E5%AE%9A%E4%B9%89%EF%BC%8C%E5%9B%A0%E6%AD%A4%E5%9C%A8%20FlexCAN%20MCAL%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8C%E4%B8%AD%E8%BF%9B%E8%A1%8C%E4%BA%86%E6%8F%8F%E8%BF%B0%EF%BC%8C%E8%AF%A5%E6%89%8B%E5%86%8C%E5%8F%AF%E5%9C%A8%E4%BB%A5%E4%B8%8B%E8%B7%AF%E5%BE%84%E4%B8%8B%E6%89%BE%E5%88%B0%EF%BC%9A%22%3CSTRONG%3EC%3A%5CNXP%5CS32DS.3.X.X%5CS32DS%5Csoftware%5CPlatformSDK_S32K3%5CRTD%5CCan_43_FLEXCAN%5Cdoc%5CRTD_CAN_43_FLEXCAN_UM.pdf%3C%2FSTRONG%3E%22%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Snag_a0158d5.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Snag_a0158d5.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F362154iC909B41A57E9BC49%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Snag_a0158d5.png%22%20alt%3D%22Snag_a0158d5.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E2.%E6%A0%B9%E6%8D%AE%20AUTOSAR%20%E6%A0%87%E5%87%86%EF%BC%8C%E6%98%AF%E7%9A%84%EF%BC%8C%E8%BF%99%E6%98%AF%E5%BC%BA%E5%88%B6%E6%80%A7%E7%9A%84%E3%80%82%E5%A4%84%E7%90%86%E9%80%BB%E8%BE%91%E5%8F%96%E5%86%B3%E4%BA%8E%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%AE%9E%E7%8E%B0%E3%80%82%E4%BE%8B%E5%A6%82%EF%BC%8C%E5%9C%A8%20FlexCAN%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E4%B8%AD%EF%BC%8C%E8%B0%83%E7%94%A8%E7%9A%84%E5%87%BD%E6%95%B0%E6%98%AF%3CSPAN%3EFlexCAN_Ip_SetStartMode()%20%E5%92%8C%20%3C%2FSPAN%3E%3CSPAN%3EFlexCAN%3C%2FSPAN%3E%20_%20Ip%20_%20SetStopMode(%20)%EF%BC%8C%20%E8%BF%99%E4%B8%A4%E4%B8%AA%E5%87%BD%E6%95%B0%E5%88%86%E5%88%AB%E5%90%AF%E7%94%A8%E5%92%8C%E7%A6%81%E7%94%A8%E6%A8%A1%E5%9D%97%E3%80%82%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAUTOSAR%20%E8%A7%84%E8%8C%83%E8%BF%98%E5%9C%A8%E5%85%B6%20CAN%20%E8%A7%84%E8%8C%83%E6%96%87%E4%BB%B6%E4%B8%AD%E6%8F%90%E4%BE%9B%E4%BA%86%E8%BF%87%E6%B8%A1%E5%9B%BE%EF%BC%9A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Snag_a0e08b2.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Snag_a0e08b2.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F362155i2F6D00495DE4E6C0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Snag_a0e08b2.png%22%20alt%3D%22Snag_a0e08b2.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E8%87%B4%E4%BB%A5%E6%9C%80%E8%AF%9A%E6%8C%9A%E7%9A%84%E9%97%AE%E5%80%99%EF%BC%8C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2190348%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAN_DeInit%20API%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2190348%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E7%8E%B0%E5%9C%A8%E6%98%8E%E7%99%BD%E4%BD%A0%E7%9A%84%E6%80%9D%E8%B7%AF%E4%BA%86%E3%80%82%E6%88%91%E6%83%B3%E7%9F%A5%E9%81%93%E8%BF%99%E4%B8%AA%E7%8A%B6%E6%80%81%E8%BD%AC%E6%8D%A2%E5%9B%BE%E6%98%AF%E5%90%A6%E6%AD%A3%E7%A1%AE%E3%80%82%E6%AD%A4%E5%A4%96%EF%BC%8C%E6%88%91%E8%BF%98%E6%9C%89%E4%B8%A4%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%9A%3CBR%20%2F%3E1.%E5%9C%A8%20MCU%20%E7%9A%84%E6%89%8B%E5%86%8C%E4%B8%AD%E5%93%AA%E9%87%8C%E5%8F%AF%E4%BB%A5%E6%89%BE%E5%88%B0%E8%BF%99%E7%A7%8D%E7%8A%B6%E6%80%81%E8%BD%AC%E6%8D%A2%EF%BC%9F%E6%88%91%E5%9C%A8%20RM%20%E4%B8%AD%E6%B2%A1%E6%9C%89%E7%9C%8B%E5%88%B0%E4%BB%BB%E4%BD%95%E7%B1%BB%E4%BC%BC%E7%9A%84%E7%8A%B6%E6%80%81%E6%8F%8F%E8%BF%B0%E3%80%82%3CBR%20%2F%3E2.%E8%BF%99%E7%A7%8D%E7%8A%B6%E6%80%81%E8%BD%AC%E6%8D%A2%E6%98%AF%E5%BC%BA%E5%88%B6%E6%80%A7%E7%9A%84%E5%90%97%EF%BC%9F%E5%85%B6%E4%BB%96%20MCU%20%E6%9E%B6%E6%9E%84%E6%98%AF%E5%90%A6%E4%B9%9F%E9%87%87%E7%94%A8%E5%90%8C%E6%A0%B7%E7%9A%84%E5%A4%84%E7%90%86%E9%80%BB%E8%BE%91%EF%BC%9F%3CBR%20%2F%3E%E9%9D%9E%E5%B8%B8%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%B8%AE%E5%8A%A9%EF%BC%81%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ModeSwitch.png%22%20style%3D%22width%3A%20844px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22ModeSwitch.png%22%20style%3D%22width%3A%20844px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361982iEC375E02605EABA1%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ModeSwitch.png%22%20alt%3D%22ModeSwitch.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2190147%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAN_DeInit%20API%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2190147%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%E6%88%91%E6%98%AF%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F213197%22%20target%3D%22_blank%22%3E%40%E5%B5%8C%E5%85%A5%E5%BC%8F%E6%96%B0%E6%89%8B%3C%2FA%3E%E3%80%81%3C%2FP%3E%0A%3CP%3E%E5%9C%A8%E8%B0%83%E7%94%A8%20CAN_DeInit%20%E4%B9%8B%E5%89%8D%EF%BC%8C%E5%B0%86%E6%89%80%E6%9C%89%E6%8E%A7%E5%88%B6%E5%99%A8%E9%83%BD%E8%AE%BE%E7%BD%AE%E4%B8%BA%20%22%E5%81%9C%E6%AD%A2%22%EF%BC%8C%E4%BB%A5%E4%BE%BF%E6%AD%A3%E5%B8%B8%E9%80%80%E5%87%BA%E8%BF%90%E8%A1%8C%EF%BC%9A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%20translate%3D%22no%22%3E%2F*%20Stop%20Can%20controller%20*%2F%0ACan_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_0%2C%20CAN_CS_STOPPED)%3B%0A%0A%2F*%20De-Initialize%20Can%20driver%20*%2F%0ACan_43_FLEXCAN_DeInit()%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E8%87%B4%E4%BB%A5%E6%9C%80%E8%AF%9A%E6%8C%9A%E7%9A%84%E9%97%AE%E5%80%99%EF%BC%8C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E