On 06/25/2010 08:37 PM, Daniel Baluta wrote: > Hi Dan, > > On Fri, Jun 25, 2010 at 6:52 PM, Dan Toganel <[email protected]> wrote: >> Hi all, >> >> I need to develop a CAN driver for SJA 1000 controller. >> What is not very clear for me is the interpretation of Bit Timing Registers. >> More exactly what is the connection between BTR0 (Baud Rate Prescaler >> and Synchronization Jump Width) and BTR1 (Time Segment 1 and Time >> Segment 2) with the Nominal Bit Time (Synchronization, Propation Time, >> Phase Buffer 1, Phase Buffer2 Segments) from CAN specification. > > Isn't Bus Timing Register instead of Bit Timing Register? > > I think you can find the relation between BTR registers and Nominal Bit Time > having a look at C 6.5.1 and 6.5.2 ([1]), and in SJA1000 source code ([2]). > >> And how can I calculate the Nominal Bit Time for a certain speed (for >> example 10 Kb/second). > > I don't know exactly how to do this, perhaps someone can help here, > but I can provide you some useful pointers ([3], [4], [5]) >> >> Can you help me?
Finding proper bit-timing parameters for certain bit-rates is not really trivial. Therefore, the Socket-CAN framework tries to calculate reasonable values for a specified bit rate. See: http://lxr.linux.no/#linux+v2.6.34/Documentation/networking/can.txt#L730 I have also a user space tool to calculate bit-timing parameters, which has been improved and posted to the Socketcan-core ml recently by Marc (search subject for "can-calc-bit-timing"). Here are the results for the SJA1000 including the value for 10 kB/s: $ ./can-calc-bit-timing sja1000 Bit timing parameters for sja1000 using 8000000Hz Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP SampP Error BTR0 BTR1 1000000 125 3 2 2 1 1 75.0% 0.0% 0x00 0x14 800000 125 5 2 2 1 1 80.0% 0.0% 0x00 0x16 500000 125 11 2 2 1 1 87.5% 0.0% 0x00 0x1c 250000 250 11 2 2 1 2 87.5% 0.0% 0x01 0x1c 125000 500 11 2 2 1 4 87.5% 0.0% 0x03 0x1c 100000 625 11 2 2 1 5 87.5% 0.0% 0x04 0x1c 50000 1250 11 2 2 1 10 87.5% 0.0% 0x09 0x1c 20000 3125 11 2 2 1 25 87.5% 0.0% 0x18 0x1c 10000 6250 11 2 2 1 50 87.5% 0.0% 0x31 0x1c Wolfgang. _______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
