S32K310 CAN Interrupt Receive

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

S32K310 CAN Interrupt Receive

Jump to solution
1,753 Views
Embedded_novice
Contributor III

我使用CAN以及CANIF配置了S32K310的CAN驱动模块。我知道调用CAN_Write()函数进行报文的发送,但我存有以下的一些问题:

1.我该如何进行报文的接收呢?我看到有一些文章说能够通过CanIf_RxIndication()函数进行接收。但是这个函数在静态代码中的逻辑应当是自动调用,而不是由我在外部主程序中调用。或者说这个函数在触发中断自动执行后将数据进行了存储,那我该如何将这些数据读取出来呢?我是否能用自己编写的回调函数去替换他?(我在MCAL的例程中没有找到使用中断的CAN例程,似乎只有POLLING模式的例程)CAN.png

2.为什么CAN的接收一定要通过CANIF而发送却可以直接由CAN驱动发出?这是否有一些规范限制我必须这样做。

感谢帮助!!

0 Kudos
Reply
1 Solution
1,730 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Embedded_novice,

1. You can look at the following training for some information on how FlexCAN works with the drivers: FLEXCAN WITH RTD AND LOW-LEVEL DRIVERS. In order to receive messages in interrupt mode, you must configure the interrupt driver (IntCtrl) and select polling = FALSE inside the FlexCAN data info structure and use "FlexCAN_Ip_Receive".

You can use this example from community post as guidance: Example S32K344 FlexCAN_Ip TX/RX/EnhanceRXFIFO DMA test S32DS3.5 RTD400 - NXP Community.

2. I imagine you are referring to the CanIf_RxIndication API? As I said in the previous response, you can use FlexCAN_Ip_Receive instead.

Best regards,
Julián

View solution in original post

0 Kudos
Reply
1 Reply
1,731 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Embedded_novice,

1. You can look at the following training for some information on how FlexCAN works with the drivers: FLEXCAN WITH RTD AND LOW-LEVEL DRIVERS. In order to receive messages in interrupt mode, you must configure the interrupt driver (IntCtrl) and select polling = FALSE inside the FlexCAN data info structure and use "FlexCAN_Ip_Receive".

You can use this example from community post as guidance: Example S32K344 FlexCAN_Ip TX/RX/EnhanceRXFIFO DMA test S32DS3.5 RTD400 - NXP Community.

2. I imagine you are referring to the CanIf_RxIndication API? As I said in the previous response, you can use FlexCAN_Ip_Receive instead.

Best regards,
Julián

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2052831%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3ES32K310%20CAN%20Interrupt%20Receive%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2052831%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20have%20configured%20the%20CAN%20driver%20module%20of%20S32K310%20using%20CAN%20and%20CANIF.%20I%20know%20that%20I%20can%20send%20messages%20by%20calling%20the%20CAN_Write()%20function%2C%20but%20I%20have%20the%20following%20questions%3A%3C%2FP%3E%3CP%3E1.%20How%20do%20I%20receive%20messages%3F%20I%20have%20seen%20some%20articles%20saying%20that%20it%20is%20possible%20to%20receive%20messages%20through%20the%20CanIf_RxIndication()%20function.%20However%2C%20the%20logic%20of%20this%20function%20in%20the%20static%20code%20should%20be%20called%20automatically%2C%20rather%20than%20by%20me%20in%20the%20external%20main%20program.%20Or%20this%20function%20stores%20the%20data%20after%20the%20interrupt%20is%20triggered%2C%20so%20how%20do%20I%20read%20the%20data%20out%3F%20Can%20I%20replace%20it%20with%20a%20callback%20function%20I%20wrote%20myself%3F%20(I%20did%20not%20find%20any%20CAN%20routines%20using%20interrupts%20in%20the%20MCAL%20routines%2C%20and%20it%20seems%20that%20there%20are%20only%20routines%20in%20POLLING%20mode)%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CAN.png%22%20style%3D%22width%3A%20775px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22CAN.png%22%20style%3D%22width%3A%20775px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326033i9ACCC73EBABC4DF1%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CAN.png%22%20alt%3D%22CAN.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E2.%20Why%20does%20CAN%20reception%20have%20to%20go%20through%20CANIF%2C%20but%20transmission%20can%20be%20directly%20sent%20by%20the%20CAN%20driver%3F%20Is%20there%20some%20specification%20that%20restricts%20me%20to%20do%20this%3F%3C%2FP%3E%3CP%3EThanks%20for%20the%20help!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2054015%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K310%20CAN%20Interrupt%20Receive%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2054015%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F213197%22%20target%3D%22_blank%22%3E%40Embedded_novice%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E1.%20You%20can%20look%20at%20the%20following%20training%20for%20some%20information%20on%20how%20FlexCAN%20works%20with%20the%20drivers%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fpwmxy87654%2Fattachments%2Fpwmxy87654%2FS32K%2F44963%2F2%2FS32K3_RTD_Training_CAN%2520(2).pdf%22%20target%3D%22_self%22%3EFLEXCAN%20WITH%20RTD%20AND%20LOW-LEVEL%20DRIVERS.%3C%2FA%3E%26nbsp%3BIn%20order%20to%20receive%20messages%20in%20interrupt%20mode%2C%20you%20must%20configure%20the%20interrupt%20driver%20(IntCtrl)%20and%20select%20polling%20%3D%20FALSE%20inside%20the%20FlexCAN%20data%20info%20structure%20and%20use%20%22%3CSTRONG%3EFlexCAN_Ip_Receive%3C%2FSTRONG%3E%22.%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20this%20example%20from%20community%20post%20as%20guidance%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FExample-S32K344-FlexCAN-Ip-TX-RX-EnhanceRXFIFO-DMA-test-S32DS3-5%2Fta-p%2F2015832%22%20target%3D%22_blank%22%3EExample%20S32K344%20FlexCAN_Ip%20TX%2FRX%2FEnhanceRXFIFO%20DMA%20test%20S32DS3.5%20RTD400%20-%20NXP%20Community%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E2.%20I%20imagine%20you%20are%20referring%20to%20the%26nbsp%3B%3CSPAN%3ECanIf_RxIndication%20API%3F%20As%20I%20said%20in%20the%20previous%20response%2C%20you%20can%20use%20FlexCAN_Ip_Receive%20instead.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E