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,323件の閲覧回数
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,283件の閲覧回数
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,268件の閲覧回数
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,256件の閲覧回数
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,314件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @ChenBowen 

Could you tell me which MCU you are using?

 

B.R.

VaneB

0 件の賞賛
返信

2,301件の閲覧回数
ChenBowen
Contributor II

MPC5744P

0 件の賞賛
返信