Some problem about FreeMASTER on CAN

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

Some problem about FreeMASTER on CAN

跳至解决方案
2,480 次查看
xflong
Contributor III

In my S32K144's project ,I atteched FreeMASTER driver v2.0. I readed the user guide,and followed the instruction.

I created the project with Processer Expert, use can0 pal for communication.

modify the "freemaster_cfg.h":

#define FMSTR_POLL_DRIVEN      1    /* No interrupt needed, polling only */

#define FMSTR_USE_FLEXCAN      1    /* To select FlexCAN communication interface */
#define FMSTR_CAN_CMDID 0x7aa   /* incoming (command) CAN message ID */
#define FMSTR_CAN_RESPID 0x7ab  /* response CAN message ID, may be the same as command ID */

In "main.c",call the init function and then poll in the for loop.

CAN_Init(&can_pal1_instance, &can_pal1_Config0);

FMSTR_Init();

for(;;)
{
      FMSTR_Poll();
}

I connect the PC host,the MCU can only send one CAN message every one reset.

I have upload the project.Could anyone help me?

1 解答
2,376 次查看
iulian_stan
NXP Employee
NXP Employee

Hi zhangbo@greatpowertech.com‌,

I noticed that in the latest SDK version (3.0.0) CAN Initialization by default enables Transmission abort mechanism (53.5.7.1 Reference Manual), and it seems it is not handled by FreeMASTER Driver that leads to all tx operations to fail, but the first one. A quick fix would be to disable it after CAN_Init call. Here's a short snippet:


    /* Enter Freeze mode */
    CAN0->MCR |= (CAN_MCR_FRZ_MASK | CAN_MCR_HALT_MASK);
    CAN0->MCR &= ~CAN_MCR_MDIS_MASK;
    while((CAN0->MCR & CAN_MCR_FRZACK_MASK ) == 0){}
    /* Disable abort mechanism  MCR[AEN] = 0 */
    CAN0->MCR &= ~CAN_MCR_AEN_MASK;
    /* Enable the FlexCAN module */
    CAN0->MCR &= ~(CAN_MCR_FRZ_MASK | CAN_MCR_HALT_MASK);

 

Regards,

Iulian

在原帖中查看解决方案

4 回复数
2,377 次查看
iulian_stan
NXP Employee
NXP Employee

Hi zhangbo@greatpowertech.com‌,

I noticed that in the latest SDK version (3.0.0) CAN Initialization by default enables Transmission abort mechanism (53.5.7.1 Reference Manual), and it seems it is not handled by FreeMASTER Driver that leads to all tx operations to fail, but the first one. A quick fix would be to disable it after CAN_Init call. Here's a short snippet:


    /* Enter Freeze mode */
    CAN0->MCR |= (CAN_MCR_FRZ_MASK | CAN_MCR_HALT_MASK);
    CAN0->MCR &= ~CAN_MCR_MDIS_MASK;
    while((CAN0->MCR & CAN_MCR_FRZACK_MASK ) == 0){}
    /* Disable abort mechanism  MCR[AEN] = 0 */
    CAN0->MCR &= ~CAN_MCR_AEN_MASK;
    /* Enable the FlexCAN module */
    CAN0->MCR &= ~(CAN_MCR_FRZ_MASK | CAN_MCR_HALT_MASK);

 

Regards,

Iulian

2,376 次查看
xflong
Contributor III

Thanks,Iulian.

It works.

0 项奖励
回复
2,376 次查看
MichalH
NXP Apps Support
NXP Apps Support

Dear flony zhang,

I confirm I'm facing the same behavior when using the project that you have sent. We are looking at the issue now and will reply as soon as we have a solution.

Thanks,

Michal

0 项奖励
回复
2,376 次查看
xflong
Contributor III

Thanks,Michal.

0 项奖励
回复