Hi Mouaaz, the Rules of Bit Timing Parameters are not described in the Philips LPC2000 User Manuals. And they are not easy. Please refer to the Bosch Homepage for more Information. But, I give you an Example that works very well in my application: Assumed that you setup the PLL and the cclk = 60 MHz and the VPB Divider = 4 (after RESET) and the pclk = 15 MHz, you can use the following parameters for a first test: // Common CAN bit rates for cclk=60 MHz, VPBDIV=4: ==> pclk=15 MHz: // CAN Bit Timings in Detail --> // SAM TSEG1 TSEG2 SJW SP% BRP #define CANBit10k_15MHz 0x25C095 // 0+1 5+1 2+1 3+1 70 149+1 #define CANBit25k_15MHz 0x25C03B // 0+1 5+1 2+1 3+1 70 59+1 #define CANBit50k_15MHz 0x25C01D // 0+1 5+1 2+1 3+1 70 29+1 #define CANBit100k_15MHz 0x25C00E // 0+1 5+1 2+1 3+1 70 14+1 #define CANBit125k_15MHz 0x25C00B // 0+1 5+1 2+1 3+1 70 11+1 #define CANBit250k_15MHz 0x25C005 // 0+1 5+1 2+1 3+1 70 5+1 #define CANBit500k_15MHz 0x25C002 // 0+1 5+1 2+1 3+1 70 2+1 #define CANBit1000k_15MHz 0x48C000 // 0+1 8+1 4+1 3+1 67 0+1 The following parameters for VPBDIV = 1 I have calculated on this base: For cclk = 60 MHz and VPBDIV = 1, the following parameters should work: // Common CAN bit rates for cclk=60 MHz, VPBDIV=1: ==> pclk=60 MHz: // CAN Bit Timings in Detail --> // SAM TSEG1 TSEG2 SJW SP% BRP #define CANBit10k_60MHz 0x25C257 // 0+1 5+1 2+1 3+1 70 599+1 #define CANBit25k_60MHz 0x25C0EF // 0+1 5+1 2+1 3+1 70 239+1 #define CANBit50k_60MHz 0x25C077 // 0+1 5+1 2+1 3+1 70 119+1 #define CANBit100k_60MHz 0x25C03B // 0+1 5+1 2+1 3+1 70 59+1 #define CANBit125k_60MHz 0x25C02F // 0+1 5+1 2+1 3+1 70 47+1 #define CANBit250k_60MHz 0x25C017 // 0+1 5+1 2+1 3+1 70 23+1 #define CANBit500k_60MHz 0x25C00B // 0+1 5+1 2+1 3+1 70 11+1 #define CANBit1000k_60MHz 0x48C003 // 0+1 8+1 4+1 3+1 67 3+1 Write this Values to the CANBTR Register. The defined CAN Bit Rates works very well in my application (Keil MCB2100 connected to a CAN Analyzer (CANalyzer from vector informatik)). The right Bit Rate Calculation is: Bit rate = cclk / ( VPBDIV * BRP * ( TSEG1+1 + 1 + TSEG2+1)) The Sample Point should be in the Range 50% to 90 %. Please download the Keil Examples for a CAN Driver, that was very helpful for me: http://www.keil.com/download/docs/lpc2_can_examples.zip.asp Greetings from Dietmar. http://www.weiss-electronic.de ----------------------------------------------------------------- --- In lpc2000@yahoogroups.com, "mouaaz" <mouaaz@y...> wrote: > > Dear all, > > I am using two LPC2129 boards having 12 MHz clock, with CCLK and PCLK > set to 60 MHz. They are connected via a CAN link. I am trying to set > the bus timing register C1BTR to run the CAN at the baudrate of 1 > Mbit/s. The value I tried is : > > C1BTR = 0x34C005; > > But it did not work. > > Anybody can help me to work out the correct setting of this register > to let the CAN go for 1 Mbaud. > > Thanks very much. > > Mouaaz > > PS. the correct setting for 125 kbaud was: C1BTR = 0x001C001D;
Message
Re: CAN baudrate setting
2005-03-05 by dietmar_wengler
Attachments
- No local attachments were found for this message.