SDK Flexcan module, How to use the api function to receive a CAN frame?

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

SDK Flexcan module, How to use the api function to receive a CAN frame?

2,291 次查看
ChenBowen
Contributor II

       I am trying to learn the SDK. I have some questions about the Flexcan module.

Typically without SDK, I poll the CAN  receive flag to receive a masage, at last write 1 to that bit to clear the flag  

For example,

if(CAN_1.IFLAG1.B.BUF6I == 1)
{
        /*

        */
        CAN_1.IFLAG1.B.BUF6I= 1;
}

     When using SDK,  do I need to poll the flag and clear it ?  It seems that flag clearing is done by api function  Flexcan_Receive() , is that right?

How to configure a CAN receive interrupt ?  Do you have a  example project? 

 

 

 

 

 

 

 

 

 

 

0 项奖励
回复
5 回复数

2,251 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

within SDK the driver itself is using MB interrupt and clear MB flag in it, moreover update internal driver variable. You can check transfer status using FLEXCAN_DRV_GetTransferStatus function or install interrupt callback.
There are 2 demo SDK examples within S32DS you can refer to.

PetrS_1-1678875363207.png

BR, Petr

 

0 项奖励
回复

2,236 次查看
ChenBowen
Contributor II

 

     

    Thank you for your replay !   

     I still have some doubt.  I discover that, once intall Can_callback function, first I must call Flexcan_Receive function to enable the rx interrupt.   

    My question is , once install the CAN callback function, will it generate interrupt every time

a msg is transmited? If so, How to disable the tx interrupt?  And the same question for error callback function, do I need to enable interrupt?   Or how can I disable the some err interrupt except the bus off 

condition as I only need to focus on the bus off state .

 

 

 

    

0 项奖励
回复

2,224 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

SDK driver is written that way, means enabling MB interrupt within Send/Receive function, so MB interrupt is always called, where internal driver variables are updated, callback called (if installed) and finally disable MB interrupt again. There is no option to disable MB interrupt, unless driver is modified, which is not recommended.

Error interrupts are enabled within FLEXCAN_DRV_InstallErrorCallback, so if you want to call it only for bus off interrupt, try to modify this function to enable mask bit for bus off only. But keep in mind again, driver modification is not recommended.

BR, Petr

0 项奖励
回复

2,282 次查看
VaneB
NXP TechSupport
NXP TechSupport

Hi @ChenBowen 

Could you tell me which MCU you are using?

 

B.R.

VaneB

0 项奖励
回复

2,269 次查看
ChenBowen
Contributor II

MPC5744P

0 项奖励
回复