Embedded Studio Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

System clock and CAN communication reliability

2 posters

Go down

System clock and CAN communication reliability Empty System clock and CAN communication reliability

Post  lyh8 Tue Aug 26, 2008 9:42 am

Hello there,

Microchip dsPIC30F4012 was chosen for our application. According to its reference design, we used 7.3728 MHz crystal to generate system clock 29.4912 MHz. I noticed that UART communication works reliably, while CAN communication does not. Can you explain why and advise any suggestion?

Thanks.

lyh8

Posts : 14
Join date : 2008-08-25

Back to top Go down

System clock and CAN communication reliability Empty Re: System clock and CAN communication reliability

Post  lzmind Tue Aug 26, 2008 11:37 am

Hi there,

You shall select a crystal or oscillator frequency so that the baud rate of the serial communication is precise enough. With your system clock 29.4912 MHz, you can generate pretty precise UART baud rate, for example, if your UART baud rate is 115200 bps, the UART baud rate generator setting can be calculated with the following equation

UxBRG = Fcy / (16 x Baudrate) – 1 = 29491200 / (16 x 115200) – 1 = 15

On the other hand, CAN communication is less tolerant than UART in terms of baud rate discrepancy. CAN baud rates are usually 125 kbps, 250 kbps, 500 kbps, and 1000 kbps. Each bit length is made up of integer units of time quanta (Tq), which is calculated with the equation below, supposing the prescale BRP = 2.

Tq = 2 x (BRP + 1) x Tcan = 2 x (2 + 1) x 1/29491200 = 203 ns

Now, suppose you want baud rate to be 250 kbps, i.e., 4000 ns bit length, the number of Tq of each bit would be 4000 / 203 = 19.7. Then if you choose 20 Tq for each bit, you end up with 246 kbps baud rate, with discrepancy = (250 – 246) / 250 = 1.6%, which caused the CAN communication reliability issue. To favor CAN communication, you’d better choose a crystal value to ensure CAN baud rate discrepancy within 1%; such values would be 7.5 MHz, 10 MHz, etc. UART can tolerate baud rate discrepancy up to around 3%. Good luck.

lzmind

Posts : 18
Join date : 2008-08-20

Back to top Go down

System clock and CAN communication reliability Empty Re: System clock and CAN communication reliability

Post  lyh8 Thu Aug 28, 2008 3:09 pm

Thank you for your great advice, lzmind.

First, we changed to 10MHz crystal, and both CAN and UART worked reliably. However, with 10 MHz crystal, the system clock can only be 20 MHz.

Second, in order to achieve max system clock, we changed to 7.5 MHz oscillator, because it is hard to find a 7.5 MHz crystal, and it turned out to be perfect solution, we achieved 30 MHz system clock, as well as reliable CAN and UART communication.

Thank you very much again for your advice.

lyh8

Posts : 14
Join date : 2008-08-25

Back to top Go down

System clock and CAN communication reliability Empty Re: System clock and CAN communication reliability

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum