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.

TM4C1294/1230 CAN issue

Hi

1. CAN data rate adaptive setting.

Below is our CAN network,  Master is TM4C1294, 120MHz. The main job is to convert UART and CAN to Ethernet. Slaver is TM4C1230, 80Mhz. focus on convert UART to CAN. 

The longest cable length is 100 meter, the most slaves up to 10-15 unit.  500kbps or step down data rate to ensure communication is successful. 

According to sprac35 CAN Bus Bit timing, set master and slave register at 500K/400K/250K/200K/100K as below table.

Master(120MHz,100m)

500K

450K

400K

350K

300K

250K

200K

150K

100K

TSEG1

8

 

9

 

11

10

6

9

6

TSEG2

1

 

2

 

4

4

3

6

4

SJW

1

 

2

 

4

4

3

4

4

BRP

24

 

25

 

25

32

60

50

109

Slaver(80MHz,100m)

500K

450K

400K

350K

300K

250K

200K

150K

100K

TSEG1

8

 

6

 

 

13

10

 

9

TSEG2

1

 

1

 

 

6

5

 

6

SJW

1

 

1

 

 

4

4

 

4

BRP

16

 

25

 

 

16

25

 

50

Master work at 500k firstly, if failed, step down to next slower data rate if detect 3 times error data rate. Fix the data rate until no error detect, We use this method to set CAN adaptive data rate because cable length is different at actual environment.

The test result is it's working well at 500kbps, but it doesn't work at other data rate. What's your advice for the adaptive data rate setting? Thanks.

2. CAN data miss during separate and recombine


Slaver 1 and Slaver 2 send data at 8bit according CAN requirement, but the package make up by many bytes. So it separate to send and then recombine. From above picture, you can see S1_3 is lost, which finally lead the whole package to be wrong. Do you have any suggestion to avoid?

3. How to improve the speed of convert CAN to Ethernet on master?

It's running on FreeRTOS, Ethernet sending by DMA method.

a. It current use PacketTransmit() from bl_emac.c, my understanding is to send one package by DMA. But why it must define NUM_TX_DESCRIPTORS to 8? 8 buffer?

b. Another way is to call tivaif_transmit() in tiva-tm4c129.c, is it a chained mode transmission?

My question is what's the difference on above two method? and how to max the speed of convert CAN to Ethernet while TM1294 will be dead once there are many times UART interruption.

  • Hello Daniel

    1. Do you mean Flexible data rate or the adaptive data rate as a method to emulate flexible data rate? TM4C devices do not support flexible data rate method.
    2. Typically the approach would be to have the first packet with a header stating a start of frame and expected data bytes in the fragmented packets to follow. Each subsequent packet to have an intermediate header followed by remaining packets and the last packet to have end of frame and remaining data bytes of the packet. This will help identify the packet missing. Also additionally checksum can be used
    3. PacketTransmit in bl_emac. is for the boot loader. You must use the tivaif_transmit for application usage.
  • Hi Amit.

    Thanks for fast reply. We can close question 3 now.

    For question 1, it's not flexible data rate, just working at several fixed data rate, try one by one. Does TM4C support this?

    For question 2, I am looking in now. Do you have some more material? thanks.
  • Hello Daniel,

    Thanks for confirming it is not flexible data rate. How does the master and slave device agree on the baud rate via scanning?

    I have a similar but not same format that I have used in the application note for audio codec porting (Section 2.3)

    www.ti.com/.../spma076.pdf
  • Thanks, Amit.

    For question 1, I will give more detail soon.

    For question 3, one more confusion. Code example and 10.3 section of TivaWare user guide use PacketTransmit() and tell us it can be called directly by the application. 

    Is the reason because of lack error checking and recovery code? So it should call tivaif_transmit() at application code.

    http://www.ti.com/lit/ug/spmu298d/spmu298d.pdf?keyMatch=tivaware%20user%20guide&tisearch=Search-EN-Everything

  • Hi Amit.

    For question 1.

    1. The test method is master work at 500kbps firstly, Slave keep at scan mode, then make decision whether jump to next lower data rate by judging LEC bit of CAN Status register, or keep at current data rate if CAN status RXOK is "1".

    2. The register setting as below table. One way is set by MAP_CANBitRateSet() function. The farthest cable length is shorter than bittiming mode when running at 500kbps. Another way is setting MAP_CANBitTimingSet() function, but it's working OK when master at 500kbps and slave is 200kbps . 

    Could you kindly have a double check below our register setting or give your recommended number? Thanks.

  • Hello Daniel

    The code example shown is for using the Etherent controller in native format. It does not mean that the IP address is acquired. How is the IP address being acquired over the network?

    If instead of scanning you set both master and slave side at the different values and commence the scanning, then does it work as expected? What I am trying to arrive is to see if the scanning is an issue.
  • Daniel, do you have any working examples for this autobaud scheme?

    I can see a node connecting to an existing network and measuring the baud rate as long as it's error transmission capability is turned off. For a network that is just starting up though I can see there being interference with the required CAN behaviour and nodes going error passive or worse going bus-off.

    Also what is the supposed advantage of this scheme? Any realtime network I've used would not benefit from such a scheme. If you can meet the requirements at x baud there is no advantage to running at 2x. If you must run at 2x to meet your requirements there is no advantage to running at x.

    Robert
  • Hi Amit,
    The code example shown is for using the Etherent controller in native format. It does not mean that the IP address is acquired. How is the IP address being acquired over the network?
    [Daniel]: Customer don't use IP acquired method, but instead of themselves method to do communication.

    If instead of scanning you set both master and slave side at the different values and commence the scanning, then does it work as expected? What I am trying to arrive is to see if the scanning is an issue.
    [Daniel]: We are testing this.

    Except above question.
    1. Can we extend to 100 meter target range at 500Kbps by MAP_CANBitRateSet? Currently it's working well at ~70 meter on network cable at 500K. Which parameter is the most important factor affect cable length? external transceiver? cable type?

    2. Don't put slave on CAN bus, then master acquire bus error because no ACK received. Mater can recover itself at 1ms or can't recover at a long time after mount slaves. Is there any function which can be called to help master recover more quickly once there CAN bus error detected( bus off, EPASS)?

    3. Can you kindly give more description about DMA Descriptors? It define UM_TX_DESCRIPTORS =8 at tivaif_transmit(), we are not sure that
    a, every Descriptors is a complete message
    b, or send out all Descriptors once enable DMA one time
    Is there any other method to improve Ethernet transmit efficiency?Thanks a lot.
  • Hello Daniel

    The cable length is an important parameter for the bit rate. As for error recovery it is very specific to the type of error being seen on the bus.

    The Ethernet being used in a raw format is something I am not familiar with. We have tested the same with lwIP and it seems to perform based on the network load.
  • Hi Amit,

    For question 2, in nterrupt function, we get bus status by call ui32Status = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);

    (1) power on master, ui32Status=0x03;
    ……
    (2) then ui32Status=0x43;
    ……
    (3) then ui32Status=0x63;
    ……
    (4) 1ms after mount slave, ui32Status=0x50;
    ……
    (5) Sometimes, can' t be recovered. ui32Status=0x63; and bus off

    In order to don't waste 1ms to wait or can't be recovered. Which function can be called to speed up master recover more quickly? Thanks.
  • Hello Daniel,

    The Bus Off condition can only be recovered when there are a certain number of messages successfully transmitted and sensed by the controller sending the message. There is no short cut to the same.