Some problem about FreeMASTER on CAN

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

Some problem about FreeMASTER on CAN

Jump to solution
2,074 Views
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 Solution
1,970 Views
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

View solution in original post

4 Replies
1,971 Views
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

1,970 Views
xflong
Contributor III

Thanks,Iulian.

It works.

0 Kudos
1,970 Views
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 Kudos
1,970 Views
xflong
Contributor III

Thanks,Michal.

0 Kudos