EmbeddedRelated.com
Forums

CAN controller 2 on the LPC2129

Started by daniela_boyo February 1, 2005

Hi everyone,

I'm having some problems using the 2nd CAN controller network on the
LPC2129 ARM board. So far I have successfully used the 1st CAN
controller and I'm now trying to incoorporate the 2nd one. I'm using
the same code as the 1st one except that I have changed the PINSEL1
register as follows:

// Enable pins for selected CAN port 2
PINSEL1 |= 0x00014000L; // Set bits 14 and 16

and all the CAN registers from 1 to 2.

Is there anything else that I am missing out that needs to be done in
software?

Any help would be greatly appreciated.

Thank you!
Daniela.


An Engineer's Guide to the LPC2100 Series


Hi Daniela,

A few weeks ago, I tried to evaluate the CAN Interface without the
demo files, only with Philips User Manual, and it ended in a big
chaos.

For this Sort of Controllers, you need a little bit source code from
the manufacturers of the controller or the compiler. If possible, use
the FullCAN Example from the Keil Homepage:

The File is called "LPC2_CAN_EXAMPLES.ZIP".

You can download it from the following link:

http://www.keil.com/download/docs/lpc2_can_examples.zip.asp

The unzipped Folder is called "LPC2_CANFull_V110".

It's not only an Example, but very professionell, one may initialise
1 to 4 CAN Interfaces by #ifdef-#endif compiler steering dependant to
the used LPC2000 Controller part (2129, 2294, eg.). The Example uses
the right PINSEL selections for each of the selected CAN Controller.

Your Pin Selection for CAN Controller 2 is right, the same as in the
FullCAN Example.

What Code and ARM Board do you use? The Keil MCB2100 or other???

I have modified the FullCAN Example to fit it to my Application,
added a Standard Group Acceptance Filter Initialisation and Auto-Bit-
Rate-Detection described in the Philips Application Note AN97076,
Page57, for the Philips SJA1000 CAN-Controller. That all costs a few
days of development but works very well on my Keil MCB2100 Board.

My Keil MCB2100 works together with a CAN Analyzer on the CAN
Controller 1 and 2 (CANalyzer from "vector informatik"), such a tool
for your PC is very useful and helpful and certainly necessary to
make decisions on bus traffic, identifiers, acceptance filters and
statistics.

Greetings from Dietmar.

www.weiss-electronic.de --------------------------

--- In , "daniela_boyo" <dob3@l...> wrote:
>
> Hi everyone,
>
> I'm having some problems using the 2nd CAN controller network on
the
> LPC2129 ARM board. So far I have successfully used the 1st CAN
> controller and I'm now trying to incoorporate the 2nd one. I'm
using
> the same code as the 1st one except that I have changed the PINSEL1
> register as follows:
>
> // Enable pins for selected CAN port 2
> PINSEL1 |= 0x00014000L; // Set bits 14 and 16
>
> and all the CAN registers from 1 to 2.
>
> Is there anything else that I am missing out that needs to be done
in
> software?
>
> Any help would be greatly appreciated.
>
> Thank you!
> Daniela.




Hi Daniella,

I'm using the 2294 and have used two of the four CAN modules without any
problem.

Here's the code I have used to set it up, you should hopefully be able to see
what's needed to initialise.

May well be basically what you've done, but it's worth a look!

Cheers,

Rob

-

// Ensure the write enable bit is set
CAN1MOD |= 1; // sic

// Switch off the acceptance filters, we want to read everything! :-)
AFMR |= 2; // Make sure the pins are enabled for the CAN modules (check this)
PINSEL1 |= 0x00054000; // Set up the CAN timimg to be 60Mhz pclk / 6 to give 10M clock, with ten
clocks per bit
// TSEG 1 = 4 (reg val 3) TSEG2 = 5 (4), SJW = 1 (0) and SAM = 1 (0)
// This gives ten clocks per bit which is 10MHz/10 = 1MHz CAN bus rate
CAN1BTR = 0x430005;

// Disable All Interrupts (alter this to enable transmit and receive...)
CAN1IER |= 0x01;

// Set CAN1 transmit 1 for 11 bit ID
CAN1TFI1 |= 0x80000000;

// Setup the CAN1 module: enable it, set dominant bit polarity etc.
CAN1MOD = 0; // sic // Now set up channel 2

// Ensure the write enable bit is set
CAN2MOD |= 1; // sic

// Set up the CAN timimg to be 60Mhz pclk / 6 to give 10M clock, with ten
clocks per bit
// TSEG 1 = 4 (reg val 3) TSEG2 = 5 (4), SJW = 1 (0) and SAM = 1 (0)
// This gives ten clocks per bit which is 10MHz/10 = 1MHz CAN bus rate
CAN2BTR = 0x430005;

// Disable All Interrupts (alter this to enable transmit and receive...)
CAN2IER |= 0x01;

// Set CAN2 transmit 1 for 11 bit ID
CAN2TFI1 |= 0x80000000;

// Setup the CAN2 module: enable it, set dominant bit polarity etc.
CAN2MOD = 0; // sic

--------------

--- In , "daniela_boyo" <dob3@l...> wrote:
>
> Hi everyone,
>
> I'm having some problems using the 2nd CAN controller network on
the
> LPC2129 ARM board. So far I have successfully used the 1st CAN
> controller and I'm now trying to incoorporate the 2nd one. I'm
using
> the same code as the 1st one except that I have changed the PINSEL1
> register as follows:
>
> // Enable pins for selected CAN port 2
> PINSEL1 |= 0x00014000L; // Set bits 14 and 16
>
> and all the CAN registers from 1 to 2.
>
> Is there anything else that I am missing out that needs to be done
in
> software?
>
> Any help would be greatly appreciated.
>
> Thank you!
> Daniela.