EmbeddedRelated.com
Forums
Memfault Beyond the Launch

LPC2119 Recieve CAN message

Started by niwa284 February 2, 2011
hi there, this is my first post here so please be patient with me.

i am working with a LPC2119 and i am trying to get the CAN interface
working. currently my code is based on the CANFull_V110 example code.
Transmitting messages is working like a charm but recieving does not work at
all. not one single message gets recieved. not even the ISRs for recieving
are called.
i tried both CAN1 and CAN2 and both show the same symptoms so i guess i can
rule out a hardware defect. the CAN driver definately delivers a correct Rx
signal to the port pins.

do i have to set something in the startup code to make can work properly?

i attached my code. hopefully someone can have a look at it and tell me what
i am doing wrong.

i am thankfull for any suggestions.

An Engineer's Guide to the LPC2100 Series

On 02/02/2011 07:09 PM, niwa284 wrote:
> [...] Transmitting messages is working like a charm but recieving
> does not work at all. not one single message gets recieved. [...]

A quick guess: You have not set the filters.

--

Timo
yes, check if you have set the bypass mode, if filters are enabled, ISRs are
not called and u dont see the incoming traffic
On Wed, Feb 2, 2011 at 9:09 AM, niwa284 wrote:

> hi there, this is my first post here so please be patient with me.
>
> i am working with a LPC2119 and i am trying to get the CAN interface
> working. currently my code is based on the CANFull_V110 example code.
> Transmitting messages is working like a charm but recieving does not work
> at all. not one single message gets recieved. not even the ISRs for
> recieving are called.
> i tried both CAN1 and CAN2 and both show the same symptoms so i guess i can
> rule out a hardware defect. the CAN driver definately delivers a correct Rx
> signal to the port pins.
>
> do i have to set something in the startup code to make can work properly?
>
> i attached my code. hopefully someone can have a look at it and tell me
> what i am doing wrong.
>
> i am thankfull for any suggestions.
>
>
hi,

bypass mode is not set and filters are also disabled. when enabling the
filters it does not change a thing.

when i poll the CAN interface i can see that there are messages recieved,
but not all and with corrupted data.
so recieving seems to be working, just the interrupts are not called for
whatever reason. Bit RIE in CANIER is set by the way.

thank you for your replies.

2011/2/3 Srinivas Acharya

> yes, check if you have set the bypass mode, if filters are enabled, ISRs
> are not called and u dont see the incoming traffic
>
> On Wed, Feb 2, 2011 at 9:09 AM, niwa284 wrote:
>
>> hi there, this is my first post here so please be patient with me.
>>
>> i am working with a LPC2119 and i am trying to get the CAN interface
>> working. currently my code is based on the CANFull_V110 example code.
>> Transmitting messages is working like a charm but recieving does not work
>> at all. not one single message gets recieved. not even the ISRs for
>> recieving are called.
>> i tried both CAN1 and CAN2 and both show the same symptoms so i guess i
>> can rule out a hardware defect. the CAN driver definately delivers a correct
>> Rx signal to the port pins.
>>
>> do i have to set something in the startup code to make can work properly?
>>
>> i attached my code. hopefully someone can have a look at it and tell me
>> what i am doing wrong.
>>
>> i am thankfull for any suggestions.
>>
>
Hello,

Could you indicate at what speed you are using CAN?

And possibly what type of board you are using?

Thank you,

Marcel

--- In l..., niwa284 wrote:
>
> hi there, this is my first post here so please be patient with me.
>
> i am working with a LPC2119 and i am trying to get the CAN interface
> working. currently my code is based on the CANFull_V110 example code.
> Transmitting messages is working like a charm but recieving does not work at
> all. not one single message gets recieved. not even the ISRs for recieving
> are called.
> i tried both CAN1 and CAN2 and both show the same symptoms so i guess i can
> rule out a hardware defect. the CAN driver definately delivers a correct Rx
> signal to the port pins.
>
> do i have to set something in the startup code to make can work properly?
>
> i attached my code. hopefully someone can have a look at it and tell me what
> i am doing wrong.
>
> i am thankfull for any suggestions.
>

the can is configured for 1MBit/s, but other speeds show the same result.
The board is a developement of the professorship i am with.

2011/2/3 m...@ymail.com

> Hello,
>
> Could you indicate at what speed you are using CAN?
>
> And possibly what type of board you are using?
>
> Thank you,
>
> Marcel
> --- In l..., niwa284 wrote:
> >
> > hi there, this is my first post here so please be patient with me.
> >
> > i am working with a LPC2119 and i am trying to get the CAN interface
> > working. currently my code is based on the CANFull_V110 example code.
> > Transmitting messages is working like a charm but recieving does not work
> at
> > all. not one single message gets recieved. not even the ISRs for
> recieving
> > are called.
> > i tried both CAN1 and CAN2 and both show the same symptoms so i guess i
> can
> > rule out a hardware defect. the CAN driver definately delivers a correct
> Rx
> > signal to the port pins.
> >
> > do i have to set something in the startup code to make can work properly?
> >
> > i attached my code. hopefully someone can have a look at it and tell me
> what
> > i am doing wrong.
> >
> > i am thankfull for any suggestions.
> >
>
--- In l..., niwa284 wrote:
>
> the can is configured for 1MBit/s, but other speeds show the same result.
> The board is a developement of the professorship i am with.
>
Have you read the errata? I don't know anything about CAN but I did notice that there is a new controller in the latest chip and that it has some differeces.

I also noted that receiver overrun can lock up the CAN controller.

What do you see in CANICR?

Are you certain that your VIC setup is correct?

Although the electrical configuration is trivial, does yours match:
http://www.olimex.com/dev/pdf/ARM/LPC/LPC-P2129-Rev.C-schematic.pdf

Richard

after some more testing it seems to be an interrupt problem and not CAN.
i tried a simple timer VIC which is not called as well.

somehow i do not even get examples with interupts running. i guess i have to
check my tool chain and experiment with it. something seems to be broken
completely.

2011/2/3 rtstofer

> --- In l..., niwa284 wrote:
> >
> > the can is configured for 1MBit/s, but other speeds show the same result.
> > The board is a developement of the professorship i am with.
> > Have you read the errata? I don't know anything about CAN but I did notice
> that there is a new controller in the latest chip and that it has some
> differeces.
>
> I also noted that receiver overrun can lock up the CAN controller.
>
> What do you see in CANICR?
>
> Are you certain that your VIC setup is correct?
>
> Although the electrical configuration is trivial, does yours match:
> http://www.olimex.com/dev/pdf/ARM/LPC/LPC-P2129-Rev.C-schematic.pdf
>
> Richard
>
>
>
--- In l..., niwa284 wrote:
>
> after some more testing it seems to be an interrupt problem and not CAN.
> i tried a simple timer VIC which is not called as well.
>
> somehow i do not even get examples with interupts running. i guess i have to
> check my tool chain and experiment with it. something seems to be broken
> completely.
I guess it would be good to know which toolchain you are using.

In the meantime, you might check your startup code to be certain the interrupt vector is actually reading the VIC.

The vector table should probably look like this:
_vectors:
ldr PC, Reset_Addr
ldr PC, Undef_Addr
ldr PC, SWI_Addr
ldr PC, PAbt_Addr
ldr PC, DAbt_Addr
nop
ldr PC, [PC,#-0xFF0] <=== THIS READS THE VIC
ldr PC, FIQ_Addr
You should also check to see that interrupts are enabled. Commonly this is done by changing mode and clearing the interrupt bits just before the branch to 'main'

MSR CPSR_c,#MODE_SVC /* enable interrupts */
b main /* Enter the C code */

Depending on the toolchain, there are more elegant solutions provided by the manufacturers.

There is also the issue that this approach to VIC handling doesn't allow for nested interrupts. If you need that, it has been discussed several times in this group. You can probably search for interrupt handler or interrupt stub or something like that.

Richard

Hi,

i just found the problem. i was lazy and used the following newlib_lpc
funktions to setup the cpu to 60MHz:

SetNativeSpeed( 12000uL);
SetDesiredSpeed( 5*12000uL);
VPBControl(VPB_DIV1);
StartClock();

now i wrote my own funktion and voila interrupts are working again. somehow
the newlib funktions mess with the IRQ system.
at the moment i can not test if the CAN Rx interrupt works but the timer IRQ
is working now so i guess the others should be fine as well. i will see
tomorrow when i get back to university.

so after all it was not my own stupidity but my lazyness.

thank you all for your time.
2011/2/3 rtstofer

> --- In l..., niwa284 wrote:
> >
> > after some more testing it seems to be an interrupt problem and not CAN.
> > i tried a simple timer VIC which is not called as well.
> >
> > somehow i do not even get examples with interupts running. i guess i have
> to
> > check my tool chain and experiment with it. something seems to be broken
> > completely.
>
> I guess it would be good to know which toolchain you are using.
>
> In the meantime, you might check your startup code to be certain the
> interrupt vector is actually reading the VIC.
>
> The vector table should probably look like this:
> _vectors:
> ldr PC, Reset_Addr
> ldr PC, Undef_Addr
> ldr PC, SWI_Addr
> ldr PC, PAbt_Addr
> ldr PC, DAbt_Addr
> nop
> ldr PC, [PC,#-0xFF0] <=== THIS READS THE VIC
> ldr PC, FIQ_Addr
>
> You should also check to see that interrupts are enabled. Commonly this is
> done by changing mode and clearing the interrupt bits just before the branch
> to 'main'
>
> MSR CPSR_c,#MODE_SVC /* enable interrupts */
> b main /* Enter the C code */
>
> Depending on the toolchain, there are more elegant solutions provided by
> the manufacturers.
>
> There is also the issue that this approach to VIC handling doesn't allow
> for nested interrupts. If you need that, it has been discussed several times
> in this group. You can probably search for interrupt handler or interrupt
> stub or something like that.
>
> Richard
>
>
>

Memfault Beyond the Launch