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.