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.

CCS: CAN PROTOCOL ON F28M36P63C2

Tool/software: Code Composer Studio

Hello,

I want to implement CAN Protocol on M3 for the first time, but it does not work...maybe I'm not using tha CAN API....

So the code is:

int main(){

 // Sets up PLL, M3 running at 75MHz and C28 running at 150MHz
    SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xf) |
                         SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 |
                         SYSCTL_XCLKDIV_OFF);
   SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);

   SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);

   GPIOPinConfigure(GPIO_PD0_CAN0RX);
    GPIOPinConfigure(GPIO_PD1_CAN0TX);
    GPIOPinTypeCAN(GPIO_PORTD_AHB_BASE,
            GPIO_PIN_0 | GPIO_PIN_1); //CAN0

// Initialize the CAN controller
          CANInit(CAN0_BASE);

          // Setup CAN to be clocked off the M3/Master subsystem clock
         CANClkSourceSelect(CAN0_BASE, CAN_CLK_M3);

        // CANBitRateSet(CAN0_BASE, 8000000, 1000000);

          CANBitRateSet(CAN0_BASE, 8000000, 500000);
          CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
          // Register interrupt handler in RAM vector table

          CANIntRegister(CAN_INT_IE0,0, CANIntHandler);
         


          CANEnable(CAN0_BASE);

tCANMsgObject sTXCANMessage;

    unsigned char messagetosend[3];

    messagetosend[0] = 0x10;
    messagetosend[0] = 0x11;
    messagetosend[0] = 0x12;



        sTXCANMessage.ulMsgID = 0x100;                        // CAN message ID - use 1
        sTXCANMessage.ulMsgIDMask = MSG_OBJ_NO_FLAGS;                    // no mask needed for TX
        sTXCANMessage.ulFlags = 0;    // enable interrupt on TX
        sTXCANMessage.ulMsgLen = sizeof(messagetosend);     // size of message is 4
        sTXCANMessage.pucMsgData =messagetosend;           // ptr to message content

        CANMessageSet(CAN0_BASE, 1, &sTXCANMessage, MSG_OBJ_TYPE_TX);



}

Would you like to help me to find a solution?

Every help will be appreciated.

Tkank you in advice....

  • Dear Salvatore Ercole, 

    Can you please tell us more specifically what is not working.  Do you see any activity on the CANTX pin?  Can you provide scope captures of CANTX pin activity?

    Please review the debug tips in this app note. http://www.ti.com/lit/an/sprace5/sprace5.pdf in section 3. You will almost always find your solution there. 

    Also please run the example at: C:\ti\controlSUITE\device_support\f28m36x\v220\F28M36x_examples_Master\can_loopback\m3   This runs in the self-test mode.  Since EXL=1, you should see some activity on the CANTX pin. 

    Please let us know if you are able to resolve your issue with the suggestions made above.

    Cheers!

    Krishna  

  • Hi Krishna Allam,

    I finally find the solution....For resolving the issue, I first defined the can message and I used the instruction CANEnable() and CANTX pin starts to change...

    But I have a question about mailboxes....If they are only 32 in order to send/recieve CAN messages, what happen if I would like to use more messages than 32?

    Thank you again for your help,

    Salvatore