The Keil examples do indeed work right. The following: #define CANBit125k_60MHz 0x25C02F // 0+1 5+1 2+1 3+1 70 47+1 also works right. He has changed the sampling intervals which is why it looks so "wrong". His comment with all those magic numbers is a note about it. James --- In lpc2000@yahoogroups.com, Greg Deuerling <egads@f...> wrote: > > See post below for full text I'm replying to... > > From: dietmar_wengler [mailto:dietmar_wengler@y...] > Sent: Saturday, March 05, 2005 4:17 PM > To: lpc2000@yahoogroups.com > Subject: [lpc2000] Re: CAN baudrate setting > > > 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 > > I have the files from the Keil link above, but it does not match/jive with > what you have posted. > > The CANALL source code has the following define: > > // Common CAN bit rates > #define CANBitrate125k_12MHz 0x001C001D > #define CANBitrate250k_12MHz 0x001C000E > > I've ran CANALL on my LPC2194 design and on Keil's MCB2100 and the above > numbers work fine. Both boards have a 12Mhz crystal, 60Mhz internal > clock, VPDIV=1; > > You say: > > #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 > > Those are WAY off from what I know to work. > Am I missing something? > > Greg Deuerling > Fermi National Accelerator Laboratory > Feynman Computing Center, Room 370, MS 368 > P.O.Box 500 Batavia, IL 60510 > (630)840-4629 FAX (630)840-5406 > Electronic Systems Engineering Group > Work: egads@f... > Personal: gdeuerling@c... > > > ________________________________________ > From: dietmar_wengler [mailto:dietmar_wengler@y...] > Sent: Saturday, March 05, 2005 4:17 PM > To: lpc2000@yahoogroups.com > Subject: [lpc2000] Re: CAN baudrate setting > > > 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; > > > > > > Yahoo! Groups Sponsor > ADVERTISEMENT > > > > > ________________________________________ > Yahoo! Groups Links > To visit your group on the web, go to: > http://groups.yahoo.com/group/lpc2000/ > > To unsubscribe from this group, send an email to: > lpc2000-unsubscribe@yahoogroups.com > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Message
Re: CAN baudrate setting
2005-03-08 by jamesasteres
Attachments
- No local attachments were found for this message.