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.

TMS570LC4357: CAN not working on Hercules Launchpad

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

I have been trying to setup CAN on my Hercules Launchpad board but I haven't had any success. I have followed this tutorial but with no success. You can see all my HALCOGEN configuration and code below.

uint8_t txtFailedMessage[] = { "Failed to Send Can Message: " };
uint8_t txtReceivedMessage[] = {"\nJust Received a Message\n"};

void CAN_init(void) {
    uint8_t txtCanInit[] = { "Initializing CAN" };
    sciDisplayText(sciREGx, txtCanInit, strlen((char*)txtCanInit));
    canInit();
}

void CAN_send(uint8_t * message) {
    if(canTransmit(canREG1, canMESSAGE_BOX1, message) == 0) {
        sciDisplayText(sciREGx, txtFailedMessage, strlen((char*)txtFailedMessage));
        while(1) {
            ;
        }
    } else {
        sciDisplayText(sciREGx, message, strlen((char*)message));
    }
}

void canMessageNotification(canBASE_t *node, uint32 messageBox) {
    sciDisplayText(sciREGx, txtReceivedMessage, strlen((char*)txtReceivedMessage));
    return;
}

void canStatusChangeNotification(canBASE_t *node, uint32 notification) {
    return;
}

void canErrorNotification(canBASE_t *node, uint32 notification) {
    return;
}

  • You have three notification functions declared; did you remove the blank/empty notification functions for those three from notification.c?
    Have you setup the VIM for the CAN interrupts ( see example_CanIntCommunication as an example)?
  • Hey Neil,

    I have tried removing the notification functions to test transmitting CAN messages and that didn't work. I also have all the VIM CAN High interrupts enabled.

    Do you have any other suggestions? 

  • When you create/place notification functions in sys_main.c, you will need to remove the placeholder functions from notification.c. Since you have done that; I suggest you step back and confirm these things.

    The code you have looks like it would support at least some basic operation. The TX would create a CAN frame. So what kind of CAN network do you have? Is there a USB CAN logger you can use? I do not see where you are calling the CAN_Init and CAN_Send. Are you setting the CAN ID before the TX?

    You might also have a launchPad HalCoGen project target that is a direct match for your launchPad device. It might be good to start with a HalCoGen target that matches your Launchpad type.
  • Hey Neil,

    I have the Hercule MCU connected to a transceiver that is directly hooked up to a USB to CAN converter that works on many different CAN setups.

    I have some other portion of the code below that calls init and transmit:

    void test_main(uint8_t * macAddress)
    {
        // Initialize the serial debug line
        sciInit();
    
        // Enable periodic interruptions
        initRTIInterrupts();
    
        IntMasterIRQEnable();
        _enable_FIQ();
        _enable_IRQ_interrupt_();
        _enable_interrupt_();
    
        printStartMessage();
    
        CAN_init();
    
        while (1)
        {
            CAN_send("1234567");
            int i = 0;
            while(i != 1000000) {
                i++;
            };
        }
    }

    Also, there is no functionality called CAN_Send for my specific version of the Hercules MCU or the need to set the ID in code (I do it in HALCOGEN).

    Also, the setup I am using is based on the project target that matches my LaunchPad device.

  • Going to a couple of more basic questions.
    Are you sure the CAN High/CAN Low wires are correctly setup?
    What rate of comm speed are you using? Is the USB adapter set with the matching value?

    Sometime a signal scope is useful to see what is happening on the comm wires.
  • I am sure that the wiring is correct. I have checked and rechecked multiple times and tried both configruations to be on the safe side.
    I am using 500k speed and it is correctly set for the board and the USB adapter.
    I also used an Oscilliscope to see what is happening and from what I saw there wasn't any signal coming from the Hercules MCU.
  • In HalCoGen, when you select the project. You should see sub menu options [General] and [Driver Enable]. In Driver enable, do you have [Enable CAN1 Driver] checked/selected?
  • I have all the required options selected on HALCOGEN.
  • Have you tried loading a launchpad demo program and been able to see CAN frames on your comm test jig network?

    You might try a power cycle by removing and re-applying the board power. Also, I suggest that you use a 120 ohm terminating resistor between CAN-H and CAN-L close to the board connectors.

    I am just guessing, but if those two things are not helpful; then I would suspect something to do with the transceiver.
  • Yousif,

    Are you able to see any output on the CAN pins from the LP at all? You should be able to see some movement on the signals on MCU side of the Transceiver at least when you send a message to the MCU from your external test tool.

    You might also want to check if there are any bus error conditions noted in the CAN error status registers and double check that you have the correct termination resistance at each node on the CAN bus.