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.

TM4C1294NCPDT: CAN BUS not working

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

I am working on EK-TM4C1294XL. I am not able to get any data from PA1_CAN0TX pin. Anything wrong in my code? my  code as below:-

void CAN0_Init(void)
{
pui8MsgData = (uint8_t *)&ui32MsgData;

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_CAN0RX);
GPIOPinConfigure(GPIO_PA1_CAN0TX);
GPIOPinTypeCAN(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
CANInit(CAN0_BASE);


// uint32_t ui32SysClock;
// ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_OSC)25000000);
// CANBitRateSet(CAN0_BASE, ui32SysClock, 500000);
/////////////////
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);


CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
IntEnable(INT_CAN0);
CANEnable(CAN0_BASE);

ui32MsgData = 0;
sCANMessage.ui32MsgID = 1;
sCANMessage.ui32MsgIDMask = 0;
sCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
sCANMessage.ui32MsgLen = sizeof(pui8MsgData);
sCANMessage.pui8MsgData = pui8MsgData;
}
//____________________________________________________________________
void CAN0_Send(void)
{
CANMessageSet(CAN0_BASE, 1, &sCANMessage, MSG_OBJ_TYPE_TX);

// SimpleDelay();
// ui32MsgData++;
ui32MsgData=0xaa;
}

  • Hello Sudip,

    You are not using the right System Clock setup API for TM4C129x devices. The API used is only applicable for TM4C123x devices.

    You need to use the following API:

        uint32_t ui32SysClock;
    
        //
        // Set the clocking to run directly from the external crystal/oscillator.
        // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
        // crystal on your board.
        //
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_OSC),
                                           25000000);
    

    Then for your bitrate setting:

        CANBitRateSet(CAN0_BASE, ui32SysClock, 500000);

    Best Regards,

    Ralph Jacobi