EmbeddedRelated.com
Forums

CAN communication between 2 LPC2129 microcontrollers

Started by ronald_smeets August 11, 2006
ps: I also used Dietmar Wenglers calculation:

Bitrate = Cclk / ((VPBDIV * (BRP+1) * (Tseg1+1+Tseg2+1+1))

Which got me to my current value 0x0014000F (BRP, Tseg1=4,
Tseg2=1, SJW=0)

Regards,
Ronald

--- In l..., "ronald_smeets" wrote:
>
> Hello everyone,
>
> I'm quite embarrased to say this, but the reason why the CAN
examples
> didn't work was totally my mistake ... it wasn't even software
> related, it was hardware :s
>
> I'll explain; on one uC the CAN is brought outside via a pinheader,
> the other uC has its CAN on a SubD connector. Might make no sense,
> but believe me, it does :) Anyway, I used flatcable with on one
side
> a SubD and on the other side just a crimp socket (so I could plug
it
> onto the pin header). Somehow I was A) asleep or B) just dumb C)
both
> because I didn't realise that the pinning on a SubD connector is
not
> the same as on a plain flatcable ... argh ;)
>
> Fixed this fault and voila, it works :) I'm not using acceptance
> filters (I followed your advice, Sten). It works fine; I'm now able
> to send ADC data from one uC to the otherone using CAN. So sorry
> everybody for all my questions :)
>
> But, I still have that question about calculating the BTR value.
> Apparantly the one I'm using now (0x0014000F) works fine, but I
still
> don't really understand how things work ...
>
> The 'insiders guide ...' tries to explain how one should calculate
> this value (I used it to calculate mine), but I don't understand
how
> they calculated the sample point value. They have a Pclk of 60Mhz
and
> want to have a bitrate op 125K and sample point of 70%. The formula
> is: Bit rate = Pclk / (BRP*(1+Tseg1+Tseg2)
>
> They say:
>
> " Using out known values:
>
> BRP`Mhz/(125k*QUANTA)
>
> Quanta has to be between 8 and 25, so one possibility is QUANTA,
> BPR0
>
> Then 16 = QUANTA = (1+Tseg1+Tseg2)
>
> So we can adjust the ratio between Tseg1 and Tseg 2 tp give us the
> desired sample point.
>
> Sample point = (QUANTAx70)/100
> Hence 16*0.7 = 11.2. This gives Tseg1, Tseg2=5 and the sample
> point h.8%"
>
> How do they calculate this 68.8% ? Maybe someone could explain it
to
> me ? It might be simple or obvious, but somehow I just don't see
it :)
>
> Thanks in advance.
> Regards,
>
> Ronald
>

An Engineer's Guide to the LPC2100 Series

ronald_smeets wrote:
> The 'insiders guide ...' tries to explain how one should calculate
> this value (I used it to calculate mine), but I don't understand how
> they calculated the sample point value. They have a Pclk of 60Mhz and
> want to have a bitrate op 125K and sample point of 70%. The formula
> is: Bit rate = Pclk / (BRP*(1+Tseg1+Tseg2)
>
> They say:
>
> " Using out known values:
>
> BRP`Mhz/(125k*QUANTA)
>
> Quanta has to be between 8 and 25, so one possibility is QUANTA,
> BPR0
>
> Then 16 = QUANTA = (1+Tseg1+Tseg2)
>
> So we can adjust the ratio between Tseg1 and Tseg 2 tp give us the
> desired sample point.
>
> Sample point = (QUANTAx70)/100
> Hence 16*0.7 = 11.2. This gives Tseg1, Tseg2=5 and the sample
> point h.8%"
>
> How do they calculate this 68.8% ? Maybe someone could explain it to
> me ? It might be simple or obvious, but somehow I just don't see it :)
>

Sample point = (1 + TSEG1 + TSEG2) / (1 + TSEG1) = 16 / 11 = 0.6875 (h.8%)

In the example they try to setup a sample point at approx. 70%. Due to rounding (10.2 -> 10) they
achieve 68.8%.

Sten
--
/************************************************
Do you need a tiny and efficient real time
operating system (RTOS) with a preemtive
multitasking for LPC2000 or AT91SAM7?

http://www.sandring-systems.de/

************************************************/
Hello Stan,

Thanks :) Hm .. 16/11 = 0.6875 ? I'm sure you mean the other way
around, right ? (11/16 = 0.6875)

Anyway, I now see it .. I worked the other way around (0.688 = 11.2 /
X) ==> X = 16.3, and I could not see how they came up with 16.3 :)

Thanks for the help.
Regards,

Ronald

>
> Sample point = (1 + TSEG1 + TSEG2) / (1 + TSEG1) = 16 / 11 0.6875 (h.8%)
>
> In the example they try to setup a sample point at approx. 70%. Due
to rounding (10.2 -> 10) they
> achieve 68.8%.
>
> Sten