Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: CAN controller 2 on the LPC2129

2005-02-19 by Robert Wood

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 lpc2000@yahoogroups.com, "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.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.