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.

CAN not working Tiva Launchpad TM4C1294

I am trying to verify CAN communication by putting a scope on the TX and RX lines.  I do not see any activity when messages are sent.  Here is the configuration code for the CAN.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinConfigure(GPIO_PA0_CAN0RX);
    GPIOPinConfigure(GPIO_PA1_CAN0TX);
    GPIOPinTypeCAN(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    // The GPIO port and pins have been set up for CAN.  The CAN peripheral
    // must be enabled.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
    // Reset the state of all the message objects and the state of the CAN
    // module to a known state.
    CANInit(CAN0_BASE);

    // Configure the controller for 1 Mbit operation.
    CANBitRateSet(CAN0_BASE, g_ui32SysClock, 1000000);
    CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
    IntEnable(INT_CAN0);
    // Take the CAN0 device out of INIT state.
    CANEnable(CAN0_BASE);


Here's how messages are being sent:

   sCANMessage.ui32MsgID = ui16MsgID;
    sCANMessage.ui32MsgIDMask = 0;
    sCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
    sCANMessage.ui32MsgLen = sizeof(msgData);
    sCANMessage.pui8MsgData = msgData;


    CANMessageSet(CAN0_BASE, 2, &sCANMessage, MSG_OBJ_TYPE_TX);

Is there some other configuration I am missing?  Does the method used to send the message correct?  Any help would be greatly appreciated.

  • Hello Lindsey

    On the TM4C129 Connected LaunchPad, CAN-0 shares the pin with UART-0. In the User manual for the LaunchPad, it mentions the jumpers that need to be changed to re-route the CAN pins. Did you make the change for the same?

    Regards

    Amit

  • Hi Amit,


    Yes I did change the jumpers.

  • Hello Lindsey,

    What is connected to the TX and RX Pin? If it is just connected to the Scope probes, it will not work. The CAN listens to the RX line when transmitting. With the RX line not connected to anything the TX pin will remain in idle state.

    If you can pull it up by setting the GPIOPUR register, it should start TX. However error flags will be received/set by CAN module

    Regards

    Amit

  • Amit Ashara said:
    If you can pull it up by setting the GPIOPUR register, it should start TX.

    Hi - usually you/Petrei/Robert or this reporter suggest the use of "CAN transceiver" IC.  That's missing here.

    Might the use of the MCU's pull-up R eliminate/escape the (requirement) for a CAN transceiver?  And - might this prove (at least somewhat pointless) as any "real CAN transaction" demands CAN transceivers (and termination Rs) at each end of the CAN link?

  • Hello cb1,

    That was not clear from the post either and that is what I asked for "What is TX and RX connected to" instead of asking for the transceiver.

    Pulling the RX line high will only cause the CAN to start transmitting but would fail checks as it would not be able to listen to itself on the line. But from a troubleshooting in absence of "information" of a Transceiver it would be OK

    Regards

    Amit

  • Hi Amit,

    OK - we're thinking much the same.

    I stand by the past advice - that any CAN troubleshooting - minus CAN transceivers - is so limited as to be of very little value.  CAN is complex enough that simple monitoring of the CAN TX line - alone - is unlikely to provide much value and/or comfort...

  • Hello cb1

    Yes, indeed it has "very little" value. It was something I observed when working with the CAN Module, that could be useful just to check if the code configures the CAN and the GPIO correctly.

    Regards

    Amit

  • To my small group's mind - use of the CAN RX pull-up R is likely to delay the commitment to proper CAN installation - which includes CAN xcvrs & termination Rs - at each end. 

    Believe if CAN is the choice - far better to embark on the real CAN path - which always demands CAN xcvr ICs and their related support components.  (to include proper - point to point - CAN appropriate cabling.) 

    Bandaid "pseudo solutions" essentially waste time/energy - CAN is sophisticated - if unwilling or fearful - a better decision is the old standby, "UART!"   

  • Hi Amit,


    I pulled up the RX line as you suggested and now I can see some data on the TX line with a scope.  What I do not understand is the data.  It seems to be the same data sent regardless of what I set as the msg ID or msg Data.  Does the CAN peripheral send some type of message before sending the actual CANMessage object? 


    Thanks,

    Lindsey

  • Hello Lindsey

    As cb1 mentioned, the CAN needs to have a Transciever before it can work as expected. This was more of a trouble shooting to get you out of the woods. If this works, then you can hook up the CAN transceiver to the CAN Controller.

    Regards

    Amit

  • To reply to the other comments, currently nothing is connected to the TX/RX.  I was attempting to confirm that the CAN peripheral was configured correctly.  Now that I am seeing some data, albeit the data makes no sense, I hope I can assume that. 

  • I will move forward with connecting the transceiver, thanks for the advice and will let you know if it works.

    Thanks,

  • Lindsey Dotson said:
    I will move forward with connecting the transceiver

    You'll do better by connecting transceivers!  (i.e. one @ each end of the CAN link - and including termination resistors - again at each end) 

    As we warned - and you've now confirmed - bandaid implementations waste time/money/effort when CAN is in play. Having both CAN, "receive  and  transmit ends" up/active will immensely boost your understanding & capability.  Note that there are 8 pin, DIP CAN xcvrs (in stock) @ hobby distys.

    We found the application files, "Simple CAN RX & Simple CAN TX" of great help in initially - getting up & running.  (those both resident w/in Examples\Peripherals\CAN)