This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069M: CAN init CANES.bit.CCE never gets set despite the enabled eCAN clock

Part Number: TMS320F28069M
Other Parts Discussed in Thread: CONTROLSUITE, LAUNCHXL-F28069M, MOTORWARE

I'm porting the controlSuite CAN example and copied the whole InitECana() function to my instaspin code. However the initialisation enters the forever loop ... while(ECanaShadow.Canes.bit.CCE != 1) I've read that I've got to check the 14th bit in SYSCTRL.PCLKCR0 and it is set (the actual value is 0100000100001100b) So the canA clock should be working. If I set the CCE bit in the memory then the program execution proceeds forward. The CAN pull ups and modes are set according to the example also.

Would you tell me what to check further?

  • If you run the ControlSuite example "as is" does the CCE bit get set? Can you scope the CANRX pin to see its logic level?
  • Both the CANRX and CANTX pins are high before trying to init the eCanA. It will take me some time to try the controlSuite because I haven't setup the environment before. I'll report once I've tested it. Please share If you have some thoughts according to the pins logic level.
  • If the CANRX pin is sensed high (bus idle condition), the CCE bit should get set. Can you post the circuit connected to the CAN pins and the scope shots showing the pin levels?
  • The circuit connection is the same as on the LAUNCHXL-F28069M. I also plugged the launchpad and experiment with it right now. I attach the oscilloscope shot from the CANRX pin.

    Here is the ECAN initialisation code in hal.c

    // CAN Setup
    GPIO_setPullup(obj->gpioHandle,GPIO_Number_30,GPIO_Pullup_Enable);
    GPIO_setPullup(obj->gpioHandle,GPIO_Number_31,GPIO_Pullup_Enable);
    GPIO_setQualification(obj->gpioHandle,GPIO_Number_30,GPIO_Qual_ASync);
    
    // CAN RX
    GPIO_setMode(obj->gpioHandle,GPIO_Number_30,GPIO_30_Mode_CANRXA);
    
    // CAN TX
    GPIO_setMode(obj->gpioHandle,GPIO_Number_31,GPIO_31_Mode_CANTXA);

    Here is the clock source to the can in hal.c:

    CLK_enableEcanaClock(obj->clkHandle);

    I'm stuck on the last loop of the following code:

    struct ECAN_REGS ECanaShadow;
    
    ENABLE_PROTECTED_REGISTER_WRITE_MODE; // EALLOW enables access to protected bits
    
    /* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/
    
    ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
    ECanaShadow.CANTIOC.bit.TXFUNC = 1;
    ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;
    
    ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
    ECanaShadow.CANRIOC.bit.RXFUNC = 1;
    ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;
    
    /* Configure eCAN for HECC mode - (reqd to access mailboxes 16 thru 31) */
    // HECC mode also enables time-stamping feature
    
    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.SCB = 1;
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    
    /* Initialize all bits of 'Message Control Register' to zero */
    // Some bits of MSGCTRL register come up in an unknown state. For proper operation,
    // all bits (including reserved bits) of MSGCTRL must be initialized to zero
    
    ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000;
    ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000;
    
    // TAn, RMPn, GIFn bits are all zero upon reset and are cleared again
    // as a matter of precaution.
    
    ECanaRegs.CANTA.all = 0xFFFFFFFF; /* Clear all TAn bits */
    
    ECanaRegs.CANRMP.all = 0xFFFFFFFF; /* Clear all RMPn bits */
    
    ECanaRegs.CANGIF0.all = 0xFFFFFFFF; /* Clear all interrupt flag bits */
    ECanaRegs.CANGIF1.all = 0xFFFFFFFF;
    
    /* Configure bit timing parameters for eCANA*/
    
    ENABLE_PROTECTED_REGISTER_WRITE_MODE;
    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.CCR = 1 ; // Set CCR = 1
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    
    // Wait until the CPU has been granted permission to change the configuration registers
    do
    {
    ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    } while(ECanaShadow.CANES.bit.CCE != 1 ); // Wait for CCE bit to be set..

  • Ok, I can confirm the ControlSuite's Example_2806xECanBack2Back works successfully on this Launchpad. The conclusion is that I have problems with my port to Motorware. Could you give me guidance how to properly port the code?
  • I found the solution to the problem.

    I had to separate this definitions to a new file can.c inside the lab project.

    #include "sw/drivers/can/src/32b/f28x/f2806x/can.h"
    
    #pragma DATA_SECTION(ECanaRegs,"ECanaRegsFile");
    volatile struct ECAN_REGS ECanaRegs;
    
    #pragma DATA_SECTION(ECanaMboxes,"ECanaMboxesFile");
    volatile struct ECAN_MBOXES ECanaMboxes;

    Then I had to copy the file F2806x_Headers_nonBIOS.cmd in the lab project directory. This is needed because of the different organisation of the memory mapping of  the controlSuite and motorware's HAL (I personally prefer the latter). The rest of the code copied from the controlSuite worked.