Some problem about FreeMASTER on CAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Some problem about FreeMASTER on CAN

ソリューションへジャンプ
2,232件の閲覧回数
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,128件の閲覧回数
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,129件の閲覧回数
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,128件の閲覧回数
xflong
Contributor III

Thanks,Iulian.

It works.

0 件の賞賛
2,128件の閲覧回数
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,128件の閲覧回数
xflong
Contributor III

Thanks,Michal.

0 件の賞賛