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.

Tiva EK-TM4C129XL CAN interrupt

Other Parts Discussed in Thread: SYSBIOS

Hi guys,

         I’m Luca and I’m working on Tiva chip TM4C129 ( or better XM4…). Now I’m using the EVB EK-TM4C129XL rev C and I’m trying to use the CAN with the interrupt.

My issue is that I’m not able to generate the interrupt in TX mode.

The code is based on LM3S9D chip (works) but I also followed the instruction on spmu298a.pdf document and TI forums suggestions.

I’m compiling with TARGET_IS_TM4C129_RA1 flags and I’m using the TivaWare_C_Series-2.1.0.12573 library.

The examples on this library in any case is not for this platform because some of the ROM function is not include on lib (for example ROM_GPIOPinTypeCAN) .

Attached the implementation and the ISR. I used the app.cfg to generate the code. The interrupt use the “interrupt number” 54.

 

void CANDriverInit()

{

    tCANMsgObject CANRecvMessage;

    //tCANBitClkParms CANBitClk;

    uint32_t freq = 0;

 

    // enable peripeheral controller for CAN0

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

 

    // configure the pins

    //should be not needed?????? - only pin 33-CAN0RC and ping 34-CAN0TX are designed to use as CAN 0

    ROM_GPIOPinConfigure(GPIO_PA0_CAN0RX);

    ROM_GPIOPinConfigure(GPIO_PA1_CAN0TX);

 

    // - not in new api  Enable the alternate function on the GPIO pins.?????

    //ROM_GPIOPinTypeCAN(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

 

    // enable and init CAN0

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);

 

    ROM_CANInit(CAN0_BASE);

 

    //ROM_CANRetrySet(CAN0_BASE, 1);

 

#ifndef PORTING_TIVA // old

    ROM_CANBitRateSet(CAN0_BASE, ROM_SysCtlClockGet(), CAN_BITRATE);

#else

    //todo - to be check

    //freq = ROM_SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    //CANSetBitTiming(CAN0_BASE, &CANBitClk); //-nothing to do

    //ROM_CANBitRateSet(CAN0_BASE, freq, CAN_BITRATE);;   //-nothing to do

    //ROM_CANBitRateSet(CAN0_BASE, ROM_SysCtlClockGet(), CAN_BITRATE);;       //-nothing to do

         ROM_CANBitRateSet(CAN0_BASE, 120000000, CAN_BITRATE);

#endif

 

    /* to test - not ok

    // @80MHz, 500kbps = 4 / 3 / 0 / 20

    tCANClkParams.ui32SyncPropPhase1Seg = 4;

    tCANClkParams.ui32Phase2Seg = 3;

    tCANClkParams.ui32SJW = 1;

    tCANClkParams.ui32QuantumPrescaler = 20;

    ROM_CANBitTimingSet(CAN0_BASE, &tCANClkParams);

 

    however, did not work following code.

 

    // @80MHz, 1000kbps = 4 / 3 / 0 / 10

    tCANClkParams.ui32SyncPropPhase1Seg = 4;

    tCANClkParams.ui32Phase2Seg = 3;

    tCANClkParams.ui32SJW = 1;

    tCANClkParams.ui32QuantumPrescaler = 10;

    ROM_CANBitTimingSet(CAN0_BASE, &tCANClkParams);

 

    CANBitClk.ui32SyncPropPhase1Seg = 5;

    CANBitClk.ui32Phase2Seg = 5;

    CANBitClk.ui32SJW = 2;

    CANBitClk.ui32QuantumPrescaler = 2;

    ROM_CANBitTimingSet(CAN0_BASE, &CANBitClk);

         */

 

    // Enable interrupt for Can event or for Bus-Off

    ROM_CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);

 

    // Enable the CAN interrupt on the processor (NVIC).

    ROM_IntEnable(INT_CAN0);

 

    ROM_CANEnable(CAN0_BASE);

 

         //not needed and not working

    //CANIntRegister(CAN0_BASE,&CANInterruptHandler);        

 

    CANRecvMessage.ui32MsgID = 0;                        // CAN msg ID - 0 for any

    CANRecvMessage.ui32MsgIDMask = 0;                    // mask is 0 for any ID

    CANRecvMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER | MSG_OBJ_EXTENDED_ID | MSG_OBJ_FIFO;

    CANRecvMessage.ui32MsgLen = 8;                       // allow up to 8 bytes

    ROM_CANMessageSet(CAN0_BASE, 1, &CANRecvMessage, MSG_OBJ_TYPE_RX);

                  

         ROM_CANMessageSet(CAN0_BASE, 2, &CANRecvMessage, MSG_OBJ_TYPE_RX);

         .....

         CANRecvMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER | MSG_OBJ_EXTENDED_ID;

    ROM_CANMessageSet(CAN0_BASE, 31, &CANRecvMessage, MSG_OBJ_TYPE_RX);         

}

 

void CANInterruptHandler(void)

{

         ...

    unsigned long mailboxNum = 0;

    mailboxNum = ROM_CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);

         ...

}

 

 

void sendMsg(..)

{

...

         CANSendMessage.ui32MsgLen = 8;

         CANSendMessage.ui32MsgID  = 1;

         CANSendMessage.ui32MsgIDMask = 0;

         CANSendMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;

 

         ROM_CANMessageSet(CAN0_BASE, 32, &CANSendMessage, MSG_OBJ_TYPE_TX);

         ..

}

Does anyone have some suggestion?

Thanks

Luca

  • Luca De Nardo said:

           //not needed and not working

        //CANIntRegister(CAN0_BASE,&CANInterruptHandler);        

       You, don't need the & at that code line.

       As you have commented this code line out, did you setup your CANInterruptHandler() at startup file?

    - kel

  • Hi Markel,

       on the app.cfg I flaged "Enable at startup". the same initailization of LM3S9D.

    In any case the function CANIntRegister(..) is in can.c file on driverlib but seems the driverlib.lib do not conteins this.

    I would try to import all the library needed for my project into my project directory and the recompile the library. But my idea is to keep the original TI library out other project in order to simplify the upgrade

    thanks

    Luca

  • Hello Luca

    Please look at the following TM4C129 CAN Example. Please note that I am using an external Transceiver to communicate between the boards.

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/363647/1280698.aspx#1280698

    Regards

    Amit

  • Hi Amit,

    thanks for suggestion. I tried the TX example and works.

    I forgot to specify that I'm using the sysbios 6.35.4.50. So should be something related to the app.cfg configuration. I'm checking if I missed something

    thanks everyone for support

    Luca

  • Hello Luca

    Sure. You may want to post it up in TI-RTOS forum for what could be the issue. There was another issue similar to yours that i moved to the TI-RTOS forum.

    Regards

    Amit

  • Hi all,

        I found the issue. It was a missing library link in one part of project. After added (or better re added becouse was added but for some strange reason disappears) I was able to added the function GPIOPinTypeCAN(GPIO_PORTA_BASE,GPIO_PIN_1 | GPIO_PIN_0);

    The only strange things is that in the SPMU363.pdf document the function ROM_GPIOPinTypeCAN does not exist but in the spmu298.pdf document the GPIOPinTypeCAN function is present. the ROM is available only for TM4C123 platform

    Thanks

    Luca