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.

TMS470MF06607: CAN transmission on DCAN2 always results in error

Part Number: TMS470MF06607
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am working for a client to deliver a project based on TMS470 micro. My first task is to get a simple scheduler working using rti (working), send a byte on UART and loop it back on same UART (Working) and finally send a fixed message on DCAN2 that is used as high speed can with an external transceiver. The drivers for all the above were generated using halcogen.

The problem: Every time I hit the can_transmit (in my 5ms task), I am getting an error notification please see the code snippet below

void Task_5ms()
{
uint8 retval = 0;

retval = canTransmit(canREG2, canMESSAGE_BOX3, ft_tx_ptr);
if(retval)
       while(hs_tx_done == 0){};     //Wait for CAN transmission to complete. This flag is set in the canMessageNotification function
sciSend(sciREG1, 8, data_UART);

}

 I see that the node->IF2DAT contains the data that I intend to send when I put a break point inside canTransmit. I have configured MESSAGE_BOX3 as transmit in halcogen, I have enabled both error and message notifications in my initialization.

Further, I put a breakpoint in the ISR and I see that it hits the ISR after calling canTransmit but always with an error! So the control always goes to error notification.

void can1HighLevelInterrupt(void)
{
uint32 value = canREG1->INT;

if (value == 0x8000U)
{
canErrorNotification(canREG1, canREG1->ES & 0x1E0U);----------------------------------------> Always goes to error notification.
return;
}

I have an up and running CAN monitoring tool connected on the bus which will send acknowledge.

I checked the ErrStat register and it displays 0xE5 most of the time. some trials the breakpoint hits as soon as I start the program and I see that the value of register is 0x05.

From the data sheet I understand that it is bit error on CAN, am I right? I even tried puttig a 120 ohm termination at the CAN_H and CAN_L lines but nothing seems to work. All am stuck with is CAN error notification. Can someone help me with way forward? How should I proceed with debugging? Please help.

Regards,

Shankar

  • The LEC field of the DCAN ES register is 5 which means a Bit 0 error. I suggest you compare the DCAN RX with the DCAN TX pin with an oscilloscope and verify that the transceiver is working properly. When TX is low, RX should also go low, driven by the transceiver.
  • Thanks bob will update about the same soon

    UPDATE

    Hello Bob,

    In the first place, when I run the canTransmit, I do not even see CANTx chaning its state. Its always stuck at 3.3V. So I do not know if watching Rx could make any sense at all. Is there a reason why Tx is not changing states? Could this be to do something with drivers?

    Regards,

    Shankar 

  • Try this: Connect a USB CAN device with logger capability on a PC and wire it to your device network. The tool will likely inform you if common CAN errors appear. It would also be good to confirm voltage and hardware connections as being correctly applied.
    Also, I had unexpected results when I used a sample project for a closely matching, but not exact match hardware. Several odd issues went away when I started with a completely new HalCoGen project that exactly matched the target.
  • Hi Parker,

    Thanks for the input. I tried this with a tool and I always see an ack error when I try to transmit a message from tool and expect my node to receive it. As I was running deeper in to the problem, I thought I should try the loop back mode (Test mode) and see if at least I can send and receive the messages in same channel. Unfortunately even that doesn't seem to work. Here is what I did.

    #define canMESSAGE_BOX1 2U
    #define canMESSAGE_BOX2 2U

    canREG1->CTL |= 0x80; // Enable test mode
    canREG1->TEST |= 0x18; // Enable internal loop back and silent mode

    canTransmit(canREG1, canMESSAGE_BOX1, hs_tx_ptr); // transmit a known message on can1

    while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX2)); //wait until message receive back on can1
    canGetData(canREG1, canMESSAGE_BOX2, hs_rx_ptr);

    while(1);

    I placed a breakpoint at while(1) and I expected hs_rx pointer buffer to hold the Tx data. TO my surprise,it did not. Am I doing something wrong here? Any help would be appreciated (rather worshiped!)

    Thanks and Regards,
    Shankar
  • I suggest you try with HalCoGen examples as a starting point.
    I am pretty sure that a messagebox must be either tx or rx, and you define canMESSAGE_BOX1 and can MESSAGE_BOX2 with the same ID (2U).  That does not appear to be what you want to do.

  • Hello I tried the halcogen examples and it doesn't work. I created a new workspace, regenerated the halcogen and I tried the example.

    Coming back to message box config, even I was stuck with that doubt. But if a loop back looks like what is shown in Page 346 10.2.3.4 of the Tech ref manual, then what are we supposed to consider? A Tx message should I have the same ID as the Rx message if I use a different identifier for both of them then the message will not go through the Rx filter so how do we understand the internal loop back? Any idea on that?

    Regards,

    Shankar

    UPDATE:

    I realized the mistake I was doing. So changed the code back to how it was generated. I dropped the idea of loop back since I did not figure out how that works. I continued observing signals on the CAN_H and CAN_L. Also I built a small system containing two other nodes that are able to transmit and receive to each other using arduino boards. I put the TMS HW as a hanging node in between them. I still have no luck. I persist to debug but am too desperate for a success now since my patience is draining out slowly.

  • Ok finally I gave up on our HW since I got the Hercules board, it looks like I had a transceiver issue on our HW. Now I have a different issue for which I open a new post. Thanks for all the support