EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Plug-an-arm (LPC2129) CAN bus problems

Started by David January 11, 2007
Hi,
I'm trying to add CAN support to some existing firmware that runs on
a plug-an-arm (from newmicros.com). I'm having trouble getting
anything CAN related to work. I have reduced my test code to some
extremely minimal test code (adapted from this book:
):

#include
#define REG32 (volatile uint32_t*)
#define GPIO1_IODIR (*(REG32 (0xE0028018)))
#define PCB_PINSEL1 (*(REG32 (0xE002C004)))
#define CAN(instance,reg_offset) (*(REG32
(0xE0044000+(((instance)-1)<<14)|(reg_offset))))
#define CANMOD 0x000
#define CANCMR 0x004
#define CANBTR 0x014
#define CANTFI1 0x030
#define CANTID1 0x034
#define CANTDA1 0x038
#define CANTDB1 0x03C

int main()
{
GPIO1_IODIR = 0xff0000;
PCB_PINSEL1 |= 0x040000;
CAN(1,CANMOD) = 1;
CAN(1,CANBTR) = 0x1c001d;
CAN(1,CANTFI1) = 0x40000;
CAN(1,CANTID1) = 0x22;
CAN(1,CANTDA1) = 0x12345678;
CAN(1,CANCMR) = 1;
while(1)
;
}

PINSEL1 is set up for CAN2 so I can change the "1"s to "2"s in the
register definitions--as far as I can tell CAN1 has a dedicated Tx
line and so there's no pins to set up for it.

CAN2 on the plug-an-arm is connected to a TJA1050 transceiver. CAN1 is
not connected to anything. I have a scope hooked up to LPC2129 pin 10
and I get nothing (it is always low). When I try using CAN2 I also get
nothing on either the TTL LPC2129 output (pin 5) or the output of the
transceiver.

I don't even care whether I have the bit-rate right yet. I just want
to see *something* come out of the chip. My ultimate goal is reading
from the CAN bus, but writing seems like an easier test.

I'm assuming I'm missing a bit in a register somewhere or some other
high level thing. Any ideas?

Thanks,
David

An Engineer's Guide to the LPC2100 Series

David Wrote
>CAN2 on the plug-an-arm is connected to a TJA1050 transceiver. CAN1 is
>not connected to anything. I have a scope hooked up to LPC2129 pin 10
>and I get nothing (it is always low). When I try using CAN2 I also get
>nothing on either the TTL LPC2129 output (pin 5) or the output of the
>transceiver.
>
>I don't even care whether I have the bit-rate right yet. I just want
>to see *something* come out of the chip. My ultimate goal is reading
>from the CAN bus, but writing seems like an easier test.

What's on the other end of the line the CAN transceiver is driving? It
almost sounds like you have a single ended network and that won't work with
CAN. The error detection and isolation HW will turn the node off almost as
soon as you start transmitting, making it hard to get a good trigger.

Robert
--------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
--- In l..., "subscriptions@..."
wrote:
>
> David Wrote
> >CAN2 on the plug-an-arm is connected to a TJA1050 transceiver. CAN1 is
> >not connected to anything. I have a scope hooked up to LPC2129 pin 10
> >and I get nothing (it is always low). When I try using CAN2 I also get
> >nothing on either the TTL LPC2129 output (pin 5) or the output of the
> >transceiver.
> >
> >I don't even care whether I have the bit-rate right yet. I just want
> >to see *something* come out of the chip. My ultimate goal is reading
> >from the CAN bus, but writing seems like an easier test.
>
> What's on the other end of the line the CAN transceiver is driving? It
> almost sounds like you have a single ended network and that won't
work with
> CAN. The error detection and isolation HW will turn the node off
almost as
> soon as you start transmitting, making it hard to get a good trigger.

Thanks for the reply. On the other end of the transceiver is a CAN-USB
device. Both ends of the bus are terminated. When sending data from
the CAN-USB device the bus looks reasonable and the TTL output of the
transceiver on the plug-an-arm also looks good. But I can't get the
plug-an-arm to send or receive.

-David
--- In l..., "David" wrote:
>
> Thanks for the reply. On the other end of the transceiver is a CAN-USB
> device. Both ends of the bus are terminated. When sending data from
> the CAN-USB device the bus looks reasonable and the TTL output of the
> transceiver on the plug-an-arm also looks good. But I can't get the
> plug-an-arm to send or receive.

I some more info after testing. If I dump the registers after I setup
the chip I get this:

# CAN Register Dump:
# CAN_AFMR = 0xe003c000: 00000002
# CAN_SFF_sa = 0xe003c004: 00000000
# CAN_SFF_GRP_sa = 0xe003c008: 00000000
# CAN_EFF_sa = 0xe003c00c: 00000000
# CAN_EFF_GRP_sa = 0xe003c010: 00000000
# CAN_ENDofTable = 0xe003c014: 00000000
# CAN_LUTerrAd = 0xe003c018: 00000000
# CAN_LUTerr = 0xe003c01c: 00000000
# CAN_TxSR = 0xe0040000: 003f3f3f
# CAN_RxSR = 0xe0040004: 0000003f
# CAN_MSR = 0xe0040008: 00000000
# CAN(2,CANMOD ) = 0xe0048000: 00000000
# CAN(2,CANCMR ) = 0xe0048004: 00000000
# CAN(2,CANGSR ) = 0xe0048008: 0000003c
# CAN(2,CANICR ) = 0xe004800c: 00000000
# CAN(2,CANIER ) = 0xe0048010: 00000001
# CAN(2,CANBTR ) = 0xe0048014: 001c0007
# CAN(2,CANEWL ) = 0xe0048018: 00000060
# CAN(2,CANSR ) = 0xe004801c: 003c3c3c
# CAN(2,CANRFS ) = 0xe0048020: 00000000
# CAN(2,CANRID ) = 0xe0048024: 00000000
# CAN(2,CANRDA ) = 0xe0048028: 00000000
# CAN(2,CANRDB ) = 0xe004802c: 00000000
# CAN(2,CANTFI1) = 0xe0048030: 00000000
# CAN(2,CANTID1) = 0xe0048034: 00000000
# CAN(2,CANTDA1) = 0xe0048038: 00000000
# CAN(2,CANTDB1) = 0xe004803c: 00000000
# CAN(2,CANTFI2) = 0xe0048040: 00000000
# CAN(2,CANTID2) = 0xe0048044: 00000000
# CAN(2,CANTDA2) = 0xe0048048: 00000000
# CAN(2,CANTDB2) = 0xe004804c: 00000000
# CAN(2,CANTFI3) = 0xe0048050: 00000000
# CAN(2,CANTID3) = 0xe0048054: 00000000
# CAN(2,CANTDA3) = 0xe0048058: 00000000
# CAN(2,CANTDB3) = 0xe004805c: 00000000

What bothers me is the CANGSR. The 0x10 and 0x20 bits are set which
means it's both sending and receiving. There is nothing on the bus and
I haven't commanded it to send anything so those bits seem suspect.
They never ever go to zero either. If I set the RM bit in the CANMOD
register to put the CAN hardware in reset mode the GSR still reads
0x3c. If I try to send a can message the GSR changes to 0x30. If I
then cancel the transmission I get a transfer interrupt (CANICR==0x0c)
that I can't seem to clear (by reading the ICR, writing 8 to the
CANCMR and clearing the interrupt in the VIC).

It feels like the hardware just isn't working right but I've tried it
on 2 different plug-an-arms and they both behave the same. I'm sure
I'm just doing something stupid...

-David
At 03:37 AM 1/11/2007 +0000, David wrote:
> I'm trying to add CAN support to some existing firmware that runs on
>a plug-an-arm (from newmicros.com). I'm having trouble getting
>anything CAN related to work. I have reduced my test code to some
>extremely minimal test code (adapted from this book:
>):

Not much help on the specifcs I'm afraid. I've used CAN but not on the
LPC. There is an application example I think in the files section. Have
you tried it?

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
--- In l..., Robert Adsett wrote:
>
> At 03:37 AM 1/11/2007 +0000, David wrote:
> > I'm trying to add CAN support to some existing firmware that runs on
> >a plug-an-arm (from newmicros.com). I'm having trouble getting
> >anything CAN related to work. I have reduced my test code to some
> >extremely minimal test code (adapted from this book:
> >):
>
> Not much help on the specifcs I'm afraid. I've used CAN but not on the
> LPC. There is an application example I think in the files section.
Have
> you tried it?

Yes, I tried the CANALL example. It looks like it is supposed to send
out a message on CAN2 and then it loops waiting for messages and
blinking LEDs. I see the LEDs blinking (so I know the codes running at
least) but my scope never triggers on the CAN2 lines. I assume this
code works on other boards (it mentions Keil's MCB2100 Development
Board in the readme), so maybe I should look for some hardware
differences between the plug-an-arm and the Keil board?

-David
At 01:47 AM 1/13/2007 +0000, David wrote:
>--- In l..., Robert Adsett wrote:
> >
> > At 03:37 AM 1/11/2007 +0000, David wrote:
> > > I'm trying to add CAN support to some existing firmware that runs on
> > >a plug-an-arm (from newmicros.com). I'm having trouble getting
> > >anything CAN related to work. I have reduced my test code to some
> > >extremely minimal test code (adapted from this book:
> > >):
> >
> > Not much help on the specifcs I'm afraid. I've used CAN but not on the
> > LPC. There is an application example I think in the files section.
> Have
> > you tried it?
>
>Yes, I tried the CANALL example. It looks like it is supposed to send
>out a message on CAN2 and then it loops waiting for messages and
>blinking LEDs. I see the LEDs blinking (so I know the codes running at
>least) but my scope never triggers on the CAN2 lines. I assume this
>code works on other boards (it mentions Keil's MCB2100 Development
>Board in the readme), so maybe I should look for some hardware
>differences between the plug-an-arm and the Keil board?

Worth a look anyway.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
--- In l..., Robert Adsett wrote:
> At 01:47 AM 1/13/2007 +0000, David wrote:
> >Yes, I tried the CANALL example. It looks like it is supposed to send
> >out a message on CAN2 and then it loops waiting for messages and
> >blinking LEDs. I see the LEDs blinking (so I know the codes running at
> >least) but my scope never triggers on the CAN2 lines. I assume this
> >code works on other boards (it mentions Keil's MCB2100 Development
> >Board in the readme), so maybe I should look for some hardware
> >differences between the plug-an-arm and the Keil board?
>
> Worth a look anyway.

So I had our hardware guy look at everything and it turns out the
schematic I got from newmicros is wrong for my plug-an-arm board. It
shows the CAN transceiver hooked up to CAN2 but ohming out the board
shows that it's really connected to CAN1. Now that that is
straightened out I can send messages and get receive interrupts. Yay!

Thanks,
David
At 10:26 PM 1/13/2007 +0000, David wrote:
>--- In l..., Robert Adsett wrote:
> > At 01:47 AM 1/13/2007 +0000, David wrote:
> > >Board in the readme), so maybe I should look for some hardware
> > >differences between the plug-an-arm and the Keil board?
> >
> > Worth a look anyway.
>
>So I had our hardware guy look at everything and it turns out the
>schematic I got from newmicros is wrong for my plug-an-arm board. It
>shows the CAN transceiver hooked up to CAN2 but ohming out the board
>shows that it's really connected to CAN1. Now that that is
>straightened out I can send messages and get receive interrupts. Yay!

Congratulations.

Robert

Another sign of the end of civilization, our technical magazines are
getting chatty
From an EETimes product descriptions 2006/08/09
".... systems that can sample gobs of inputs simultaneously"
Now just what is the technical definition for gobs again?
http://www.aeolusdevelopment.com/

Memfault Beyond the Launch