MPC5744p flexCAN gets stuck in freeze acknowledge

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

MPC5744p flexCAN gets stuck in freeze acknowledge

Jump to solution
1,383 Views
ivanjuresa
Contributor II

Evening, 

We are developing a bootloader application for MPC5744p along with test application for that bootloader. Bootloader is communicating with PC application through flexCAN. PC application is developed by us and it is working with CCP protocol. 

When debugging both applications separately, they both work as intended. Applications are simple, just LED blinking. The problem is when the bootloader application is running and we flash the test application through our PC application everything works as intended but LED is not blinking.

If we attach on running application (test application) we can see that it is stuck in line:

while (!CAN_0.MCR.B.FRZACK) {}‍‍

After resuming application flexCAN is initialized and LED is blinking.

Both applications have the same drivers. We are still not using our drivers but yours from various test examples. Below are links to them.

flexCAN init function: [C] void InitCAN_0(uint8_t bootloadMessageID) { /* General init. No MB - Pastebin.com 

clock initialization: [C] void MC_MODE_INIT(void) { // TODO: Check MC_ME.ME.R = 0x000005FF; - Pastebin.com 

Thanks for your help,

Regards,

Ivan Jureša

1 Solution
905 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ivan,

most probably the Freeze mode is not entered again, because the HALT bit is cleared at the end of init code.

The module enters Freeze mode if FRZ bit = 1 and the HALT bit is set or a debug mode is entered.

So modify the beginning of Init function. For example as below...


/* FlexCAN module register's bit masks */
#define CAN_MCR_MDIS        0x80000000
#define CAN_MCR_FRZ         0x40000000
#define CAN_MCR_FEN         0x20000000
#define CAN_MCR_HALT        0x10000000
#define CAN_MCR_NOTRDY      0x08000000
#define CAN_MCR_SOFTRST     0x02000000
#define CAN_MCR_FRZACK      0x01000000
#define CAN_MCR_WRNEN       0x00200000
#define CAN_MCR_LPMACK      0x00100000
#define CAN_MCR_SRXDIS      0x00020000
#define CAN_MCR_BCC         0x00010000
#define CAN_MCR_LPRIOEN     0x00002000
#define CAN_MCR_AEN         0x00001000

void FlexCAN0_Init(void)
{

/* enable the FlexCAN module, reset and freeze */
    CAN_0.MCR.R = (0
                    | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
                    | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */
                    //| CAN_MCR_SRXDIS  /* self reception enabled */
                    | CAN_MCR_BCC  /* individual Rx masking and queue */
                    | 0x0000003F);                      
   
    /* double check that we are actually in freeze mode */
    while(0 == CAN_0.MCR.B.FRZACK) {};
    while(0 == CAN_0.MCR.B.NOTRDY) {};
    
    CAN_0.MCR.R = (0
                    | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
                    | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */                    
                    /*| CAN_MCR_SRXDIS */ /* self reception enabled */
                    | CAN_MCR_BCC  /* individual Rx masking and queue */
                    | CAN_MCR_AEN  /* Safe Tx abort enable */
                    | 0x0000003F); /* enable 64 MBs */  

// do other initialization

/* Finally clear the HALT flag in MCR to enable the FlexCAN
     * to synchronize with the CAN bus and allow
     * participation in communication. */
    CAN_0.MCR.B.HALT = 0;
    
    /* wait until FlexCAN ready */
    while(1 == CAN_0.MCR.B.FRZACK) {}
    while(1 == CAN_0.MCR.B.NOTRDY) {}

}

BR, Petr

View solution in original post

1 Reply
906 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ivan,

most probably the Freeze mode is not entered again, because the HALT bit is cleared at the end of init code.

The module enters Freeze mode if FRZ bit = 1 and the HALT bit is set or a debug mode is entered.

So modify the beginning of Init function. For example as below...


/* FlexCAN module register's bit masks */
#define CAN_MCR_MDIS        0x80000000
#define CAN_MCR_FRZ         0x40000000
#define CAN_MCR_FEN         0x20000000
#define CAN_MCR_HALT        0x10000000
#define CAN_MCR_NOTRDY      0x08000000
#define CAN_MCR_SOFTRST     0x02000000
#define CAN_MCR_FRZACK      0x01000000
#define CAN_MCR_WRNEN       0x00200000
#define CAN_MCR_LPMACK      0x00100000
#define CAN_MCR_SRXDIS      0x00020000
#define CAN_MCR_BCC         0x00010000
#define CAN_MCR_LPRIOEN     0x00002000
#define CAN_MCR_AEN         0x00001000

void FlexCAN0_Init(void)
{

/* enable the FlexCAN module, reset and freeze */
    CAN_0.MCR.R = (0
                    | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
                    | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */
                    //| CAN_MCR_SRXDIS  /* self reception enabled */
                    | CAN_MCR_BCC  /* individual Rx masking and queue */
                    | 0x0000003F);                      
   
    /* double check that we are actually in freeze mode */
    while(0 == CAN_0.MCR.B.FRZACK) {};
    while(0 == CAN_0.MCR.B.NOTRDY) {};
    
    CAN_0.MCR.R = (0
                    | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
                    | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */                    
                    /*| CAN_MCR_SRXDIS */ /* self reception enabled */
                    | CAN_MCR_BCC  /* individual Rx masking and queue */
                    | CAN_MCR_AEN  /* Safe Tx abort enable */
                    | 0x0000003F); /* enable 64 MBs */  

// do other initialization

/* Finally clear the HALT flag in MCR to enable the FlexCAN
     * to synchronize with the CAN bus and allow
     * participation in communication. */
    CAN_0.MCR.B.HALT = 0;
    
    /* wait until FlexCAN ready */
    while(1 == CAN_0.MCR.B.FRZACK) {}
    while(1 == CAN_0.MCR.B.NOTRDY) {}

}

BR, Petr