EmbeddedRelated.com
Forums

CAN communication between 2 LPC2129 microcontrollers

Started by ronald_smeets August 11, 2006
Dear all,

I'm working on a project with 2 LPC2129 microcontrollers. I want them
to communicate with eachother using CAN. The hardware setup of both
controllers is 'adapted' from the MCB2100 Evaluation board (so with
the same CAN driver IC's etc). The microcontrollers run on a 16Mhz
crystal, with PLL multiplier set to 4 and VPBDIV also to 4.

Now I want to transmit data from CAN1 on uC1 to CAN1 on uC2. I
therefor want to use the examples 25 (CANTX) and 26 (CANRX) mentioned
in "The Insiders Guide To The Philips ARM7-Based Microcontrollers",
but somehow I can't get things to work ... I first want to get the
tranmitting part correct, before I even continue onto the receiving
part.

But what I see now (according to the C1SR status register) is that
data gets transmitted, but the CAN1 has to receive (an ACK?) back
otherwise the C1SR status register will always indicate that there is
something transmitting on CAN1 and therefor no new value can be
tranmitted (I hope you understand what I'm trying to say here). So
this would mean I have to setup the receiving side first ?

Hm .. I can't the hang of CAN yet, so I hope someone can help me out.
Basically this is what I like to have:

1) code to transmit data via CAN1 on one microcontroller
2) code to receive this data on CAN1 of the other microcontroller
(basically code to check if CAN works on the prototype PCB I work on)
3) a good explanation of the BTR setting. I have found quite some
information around here, but still I find it hard to understand. The
transmission speed is not crucial yet, but I tried to keep to the
125k setting)
Anyway, here's what I got so far for transmitting data via CAN1:

void main(void)
{
init_uC(); // Basic things like setting UART, SPI, PINSEL etc.

/* Taken from CAN Tx example */
PINSEL1 |= 0x00014000; // Enable Pin 0.25 as CAN1 RX
C1MOD = 0x00000001; // Set CAN Controller into Reset
C1BTR = 0x0014000F; // Set Bit Timing to 125k
C1MOD = 0x00000000; // Release CAN Controller

/* Other things I have to do, like setting an ADC etc (nothing to do
with CAN anyway)
program_MS3110();
DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
send_SPI1(0xFE); // Perform complete reset (has to be done first!)
DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
init_ADC();
ADC_Selfcal();
DRDY_HL_CHK();
send_SPI1(0x10);
send_SPI1(0x04);
for (t=0;t<400;t++) // Wait a while for data to be ready
{} //(>> t6 - see datasheet of ADC)
send_SPI1(0x03);
for (t=0;t<400;t++) // Wait a while for data to be ready
{} //(>> t6 - see datasheet of ADC)

while(1)
{
/* Taken from CAN Tx example */
C1TFI1 = 0x00040000; // Set DLC to 4 Bytes
C1TID1 = 0x00000002; // Set addesss to 2 Standard Frame

/* Get data from ADC (works fine)*/
DRDY_HL_CHK();
MSB = read_SPI1(); //Read MSB
MB = read_SPI1(); //Read MidByte
LSB = read_SPI1(); //Read LSB
Value = 0;
Value |= (MSB << 16);
Value |= (MB << 8);
Value |= LSB;
Value ^= 0x00800000;

/* Taken from CAN Tx example */
printf("C1SR: %x\n", C1SR);
if (C1SR & 0x00000004)
{
C1TDA1 = Value; // Copy value into first four bytes
C1CMR = 0x00000021; // Transmit the message
}
/* ****** */

printf("%d\n", Value); // Just to make sure program runs ...
}
}

Maybe someone can help me out with this or at least give me some tips
to put me in the right direction :) I have tried to work through
the "LPC2_CAN_examples", but I just can't get through it (they seem
to do a lot more than I want) ...

Thanks in advance.
Regards,

Ronald

An Engineer's Guide to the LPC2100 Series

Hi Ronald,

you have to have a working received to be able to transmit on the CAN bus.
This is because at least one other nodedon the bus has to ACK the sent
frame. If not ACK'ed the frame will be sent again and again until the error
counter take it of the bus.

Best is to have one CAN adapter that one knwos is working and start to
debug from there. If you don't you have to fix both sides at the same time.
Harder but not impossible,
Regards
/Ake
On 8/11/06, ronald_smeets wrote:
>
> Dear all,
>
> I'm working on a project with 2 LPC2129 microcontrollers. I want them
> to communicate with eachother using CAN. The hardware setup of both
> controllers is 'adapted' from the MCB2100 Evaluation board (so with
> the same CAN driver IC's etc). The microcontrollers run on a 16Mhz
> crystal, with PLL multiplier set to 4 and VPBDIV also to 4.
>
> Now I want to transmit data from CAN1 on uC1 to CAN1 on uC2. I
> therefor want to use the examples 25 (CANTX) and 26 (CANRX) mentioned
> in "The Insiders Guide To The Philips ARM7-Based Microcontrollers",
> but somehow I can't get things to work ... I first want to get the
> tranmitting part correct, before I even continue onto the receiving
> part.
>
> But what I see now (according to the C1SR status register) is that
> data gets transmitted, but the CAN1 has to receive (an ACK?) back
> otherwise the C1SR status register will always indicate that there is
> something transmitting on CAN1 and therefor no new value can be
> tranmitted (I hope you understand what I'm trying to say here). So
> this would mean I have to setup the receiving side first ?
>
> Hm .. I can't the hang of CAN yet, so I hope someone can help me out.
> Basically this is what I like to have:
>
> 1) code to transmit data via CAN1 on one microcontroller
> 2) code to receive this data on CAN1 of the other microcontroller
> (basically code to check if CAN works on the prototype PCB I work on)
> 3) a good explanation of the BTR setting. I have found quite some
> information around here, but still I find it hard to understand. The
> transmission speed is not crucial yet, but I tried to keep to the
> 125k setting)
>
> Anyway, here's what I got so far for transmitting data via CAN1:
>
> void main(void)
> {
> init_uC(); // Basic things like setting UART, SPI, PINSEL etc.
>
> /* Taken from CAN Tx example */
> PINSEL1 |= 0x00014000; // Enable Pin 0.25 as CAN1 RX
> C1MOD = 0x00000001; // Set CAN Controller into Reset
> C1BTR = 0x0014000F; // Set Bit Timing to 125k
> C1MOD = 0x00000000; // Release CAN Controller
>
> /* Other things I have to do, like setting an ADC etc (nothing to do
> with CAN anyway)
> program_MS3110();
> DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
> send_SPI1(0xFE); // Perform complete reset (has to be done first!)
> DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
> init_ADC();
> ADC_Selfcal();
> DRDY_HL_CHK();
> send_SPI1(0x10);
> send_SPI1(0x04);
> for (t=0;t<400;t++) // Wait a while for data to be ready
> {} //(>> t6 - see datasheet of ADC)
> send_SPI1(0x03);
> for (t=0;t<400;t++) // Wait a while for data to be ready
> {} //(>> t6 - see datasheet of ADC)
>
> while(1)
> {
> /* Taken from CAN Tx example */
> C1TFI1 = 0x00040000; // Set DLC to 4 Bytes
> C1TID1 = 0x00000002; // Set addesss to 2 Standard Frame
>
> /* Get data from ADC (works fine)*/
> DRDY_HL_CHK();
> MSB = read_SPI1(); //Read MSB
> MB = read_SPI1(); //Read MidByte
> LSB = read_SPI1(); //Read LSB
> Value = 0;
> Value |= (MSB << 16);
> Value |= (MB << 8);
> Value |= LSB;
> Value ^= 0x00800000;
>
> /* Taken from CAN Tx example */
> printf("C1SR: %x\n", C1SR);
> if (C1SR & 0x00000004)
> {
> C1TDA1 = Value; // Copy value into first four bytes
> C1CMR = 0x00000021; // Transmit the message
> }
> /* ****** */
>
> printf("%d\n", Value); // Just to make sure program runs ...
> }
> }
>
> Maybe someone can help me out with this or at least give me some tips
> to put me in the right direction :) I have tried to work through
> the "LPC2_CAN_examples", but I just can't get through it (they seem
> to do a lot more than I want) ...
>
> Thanks in advance.
> Regards,
>
> Ronald
>
>
>
Hello Ake,

Thank you for your quick reply. Ok, well this is a start. By looking
at the C1SR register I also figured out that the CAN controller was
waiting for an ACK. So now I first need to get the receiving part
correctly. Do you have any suggestions, code examples maybe ?

I don't have a working, external CAN adapter, so I'll have to do with
the hardware (the 2 LPCs) I've got :)

The CANRX example (mentioned in the 'Insiders Guide ...') defines
Acceptance filters. Do you have to use them or are they optional ? My
guess is that I don't need them, because I only have one receiving
CAN controller and this one has to get all data send by the
transmitting uC.

So basically I like to have an example of receiving data via CAN bus
and sending ACK back to the sender (without all the acceptance
filters etc).

Hm, and I still like to have a good explanation about the BTR
settings :D

Thanks again for your reply.
Regards,

Ronald
--- In l..., YAP wrote:
>
> Hi Ronald,
>
> you have to have a working received to be able to transmit on the
CAN bus.
> This is because at least one other nodedon the bus has to ACK the
sent
> frame. If not ACK'ed the frame will be sent again and again until
the error
> counter take it of the bus.
>
> Best is to have one CAN adapter that one knwos is working and
start to
> debug from there. If you don't you have to fix both sides at the
same time.
> Harder but not impossible,
> Regards
> /Ake
>
ronald_smeets wrote:
> Dear all,
>
> I'm working on a project with 2 LPC2129 microcontrollers. I want them
> to communicate with eachother using CAN. The hardware setup of both
> controllers is 'adapted' from the MCB2100 Evaluation board (so with
> the same CAN driver IC's etc). The microcontrollers run on a 16Mhz
> crystal, with PLL multiplier set to 4 and VPBDIV also to 4.
>
> Now I want to transmit data from CAN1 on uC1 to CAN1 on uC2. I
> therefor want to use the examples 25 (CANTX) and 26 (CANRX) mentioned
> in "The Insiders Guide To The Philips ARM7-Based Microcontrollers",
> but somehow I can't get things to work ... I first want to get the
> tranmitting part correct, before I even continue onto the receiving
> part.
>
> But what I see now (according to the C1SR status register) is that
> data gets transmitted, but the CAN1 has to receive (an ACK?) back
> otherwise the C1SR status register will always indicate that there is
> something transmitting on CAN1 and therefor no new value can be
> tranmitted (I hope you understand what I'm trying to say here). So
> this would mean I have to setup the receiving side first ?
>
> Hm .. I can't the hang of CAN yet, so I hope someone can help me out.
> Basically this is what I like to have:
>
> 1) code to transmit data via CAN1 on one microcontroller
> 2) code to receive this data on CAN1 of the other microcontroller
> (basically code to check if CAN works on the prototype PCB I work on)
> 3) a good explanation of the BTR setting. I have found quite some
> information around here, but still I find it hard to understand. The
> transmission speed is not crucial yet, but I tried to keep to the
> 125k setting)
> Anyway, here's what I got so far for transmitting data via CAN1:
>
> void main(void)
> {
> init_uC(); // Basic things like setting UART, SPI, PINSEL etc.
>
> /* Taken from CAN Tx example */
> PINSEL1 |= 0x00014000; // Enable Pin 0.25 as CAN1 RX
> C1MOD = 0x00000001; // Set CAN Controller into Reset
> C1BTR = 0x0014000F; // Set Bit Timing to 125k
> C1MOD = 0x00000000; // Release CAN Controller
>
> /* Other things I have to do, like setting an ADC etc (nothing to do
> with CAN anyway)
> program_MS3110();
> DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
> send_SPI1(0xFE); // Perform complete reset (has to be done first!)
> DRDY_HL_CHK(); // Wait for DRDY pin to go High and Low
> init_ADC();
> ADC_Selfcal();
> DRDY_HL_CHK();
> send_SPI1(0x10);
> send_SPI1(0x04);
> for (t=0;t<400;t++) // Wait a while for data to be ready
> {} //(>> t6 - see datasheet of ADC)
> send_SPI1(0x03);
> for (t=0;t<400;t++) // Wait a while for data to be ready
> {} //(>> t6 - see datasheet of ADC)
>
> while(1)
> {
> /* Taken from CAN Tx example */
> C1TFI1 = 0x00040000; // Set DLC to 4 Bytes
> C1TID1 = 0x00000002; // Set addesss to 2 Standard Frame
>
> /* Get data from ADC (works fine)*/
> DRDY_HL_CHK();
> MSB = read_SPI1(); //Read MSB
> MB = read_SPI1(); //Read MidByte
> LSB = read_SPI1(); //Read LSB
> Value = 0;
> Value |= (MSB << 16);
> Value |= (MB << 8);
> Value |= LSB;
> Value ^= 0x00800000;
>
> /* Taken from CAN Tx example */
> printf("C1SR: %x\n", C1SR);
> if (C1SR & 0x00000004)
> {
> C1TDA1 = Value; // Copy value into first four bytes
> C1CMR = 0x00000021; // Transmit the message
> }
> /* ****** */
>
> printf("%d\n", Value); // Just to make sure program runs ...
> }
> }
>
> Maybe someone can help me out with this or at least give me some tips
> to put me in the right direction :) I have tried to work through
> the "LPC2_CAN_examples", but I just can't get through it (they seem
> to do a lot more than I want) ...
>
> Thanks in advance.
> Regards,
>
> Ronald

Hello Ronald,

to get your communication working you need at least two CAN controller configured for normal
operation on your CAN bus. At the end of a CAN message there is 1-bit acknowledge gap in which each
CAN controller on the bus (which is not in listen-only mode) must send a dominant bit (0) to
acknowledge this message on the bus. If sending controller did not see this acknowledge, it will
interrupt transmission by sending a packet with a number of dominant bits, which are violating bit
stuffing rules, and is re-transmitting this packet. This procedure takes place until packet was
successfully sent on the bus (sender received an ACK) or sender falls into bus-passive mode (too
many retries) and waits until a bus-recovery condition.

With the BTR settings you can configure the exact bit sample point and the clock synchronisation.
SJW is the synchronization jump width. It defines the number clocks which are allowed to shift
internal bit timing generator to synchronize to timing of a receiving message. TSEG1 and TSEG2
define the sample point and the number of clocks/bit. Sample is taken after TSEG1. Sample point
should be between 60..85%. In most automotive application this point is set to appr. 80%.

Sten

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

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

************************************************/
Hello Sten,

Thank you too for your reply and your information about how CAN
works. What exactly do you mean with 'normal operation' ? Can you
help me out with an example about how I can get one microcontroller
to just 'listen' and receive data send by the other
microcontroller ?.

This is the code from the CANRX example I would like to use:

int main(void)
{
init_CAN2();

VPBDIV = 0x00000001; //Set PClk to 60Mhz
IODIR1 = 0x00FF0000; // set all ports to output
PINSEL1 |= 0x00040000; //Enable Pin 0.25 as CAN1 RX
C1MOD = 0x00000001; //Set CAN controller into reset
C1BTR = 0x001C001D; //Set bit timing to 125k
C1IER = 0x00000001; //Enable the Receive interrupt
VICVectCntl0 = 0x0000003A; //select a priority slot for a given
interrupt
VICVectAddr0 = (unsigned)CAN1IRQ; //pass the address of the IRQ into
the VIC slot
VICIntEnable = 0x04000000; //enable interrupt
AFMR = 0x00000001; //Disable the Acceptance filters to
allow setup of the table
StandardFilter[0] = 0x20012002;
StandardFilter[1] = 0x20032004;
GroupStdFilter[0] = 0x2009200F;
GroupStdFilter[1] = 0x20112020;
IndividualExtFilter[0] = 0x40010000;
IndividualExtFilter[1] = 0x40020000;
GroupExtFilter[0] = 0x40030000;
GroupExtFilter[2] = 0x40040000;
SFF_sa = 0x00000000; //Set start address of Standard table
SFF_GRP_sa = 0x00000010; //Set start address of Standard group
table
EFF_sa = 0x00000018; //Set start address of Extended table
EFF_GRP_sa = 0x00000020; //Set start address of Extended group
table
ENDofTable = 0x00000028; //Set end of table address
AFMR = 0x00000000; //Enable Acceptance filters

C1MOD = 0x00000000; //Release CAN controller

while(1)
{
TX_CAN2();
}
}

void CAN1IRQ (void) __irq
{

IOCLR1 = ~C1RDA<<8; //clear output pins
IOSET1 = C1RDA<<8; //set output pins
C1CMR = 0x00000004; //release the recieve buffer
VICVectAddr = 0x00000000; //Signal the end of interrupt
}

As far as I see it, this program sends ADC values (from MCB2100
board) via CAN2 and receives data via CAN1. But how work the
Acceptance Filters ? Do you need them if you only have 2 CAN
controllers (one sending, one receiving) ?

Thanks in advance.
Regards,

Ronald

> Hello Ronald,
>
> to get your communication working you need at least two CAN
controller configured for normal
> operation on your CAN bus. At the end of a CAN message there is 1-
bit acknowledge gap in which each
> CAN controller on the bus (which is not in listen-only mode) must
send a dominant bit (0) to
> acknowledge this message on the bus. If sending controller did not
see this acknowledge, it will
> interrupt transmission by sending a packet with a number of
dominant bits, which are violating bit
> stuffing rules, and is re-transmitting this packet. This procedure
takes place until packet was
> successfully sent on the bus (sender received an ACK) or sender
falls into bus-passive mode (too
> many retries) and waits until a bus-recovery condition.
>
> With the BTR settings you can configure the exact bit sample point
and the clock synchronisation.
> SJW is the synchronization jump width. It defines the number clocks
which are allowed to shift
> internal bit timing generator to synchronize to timing of a
receiving message. TSEG1 and TSEG2
> define the sample point and the number of clocks/bit. Sample is
taken after TSEG1. Sample point
> should be between 60..85%. In most automotive application this
point is set to appr. 80%.
>
> Sten
>
> --
> /************************************************
> Do you need a tiny and efficient real time
> operating system (RTOS) with a preemtive
> multitasking for LPC2000?
>
> http://www.sandring-systems.de/
>
> ************************************************/
>
Hi,

I think there is a CAN sample in filesection of this list IIRC. Also I
belive Embedded Systems Academy http://www.esacademy.com/ got a sample.

/Ake

On 8/11/06, ronald_smeets wrote:
>
> Hello Ake,
>
> Thank you for your quick reply. Ok, well this is a start. By looking
> at the C1SR register I also figured out that the CAN controller was
> waiting for an ACK. So now I first need to get the receiving part
> correctly. Do you have any suggestions, code examples maybe ?
>
> I don't have a working, external CAN adapter, so I'll have to do with
> the hardware (the 2 LPCs) I've got :)
>
> The CANRX example (mentioned in the 'Insiders Guide ...') defines
> Acceptance filters. Do you have to use them or are they optional ? My
> guess is that I don't need them, because I only have one receiving
> CAN controller and this one has to get all data send by the
> transmitting uC.
>
> So basically I like to have an example of receiving data via CAN bus
> and sending ACK back to the sender (without all the acceptance
> filters etc).
>
> Hm, and I still like to have a good explanation about the BTR
> settings :D
>
> Thanks again for your reply.
> Regards,
>
> Ronald
> --- In l... , YAP
> wrote:
> >
> > Hi Ronald,
> >
> > you have to have a working received to be able to transmit on the
> CAN bus.
> > This is because at least one other nodedon the bus has to ACK the
> sent
> > frame. If not ACK'ed the frame will be sent again and again until
> the error
> > counter take it of the bus.
> >
> > Best is to have one CAN adapter that one knwos is working and
> start to
> > debug from there. If you don't you have to fix both sides at the
> same time.
> > Harder but not impossible,
> >
> >
> > Regards
> > /Ake
> >
>
Hello,

Thanks. The CAN examples in this list I allready have. I'll check out
the ones at Embedded Systems Academy.

Regards,
Ronald

--- In l..., YAP wrote:
>
> Hi,
>
> I think there is a CAN sample in filesection of this list IIRC. Also
I
> belive Embedded Systems Academy http://www.esacademy.com/ got a
sample.
>
> /Ake
>
ronald_smeets wrote:
> Hello Sten,
>
> Thank you too for your reply and your information about how CAN
> works. What exactly do you mean with 'normal operation' ? Can you
> help me out with an example about how I can get one microcontroller
> to just 'listen' and receive data send by the other
> microcontroller ?.
>
> This is the code from the CANRX example I would like to use:
>
> int main(void)
> {
> init_CAN2();
>
> VPBDIV = 0x00000001; //Set PClk to 60Mhz
> IODIR1 = 0x00FF0000; // set all ports to output
> PINSEL1 |= 0x00040000; //Enable Pin 0.25 as CAN1 RX
> C1MOD = 0x00000001; //Set CAN controller into reset
> C1BTR = 0x001C001D; //Set bit timing to 125k
> C1IER = 0x00000001; //Enable the Receive interrupt
> VICVectCntl0 = 0x0000003A; //select a priority slot for a given
> interrupt
> VICVectAddr0 = (unsigned)CAN1IRQ; //pass the address of the IRQ into
> the VIC slot
> VICIntEnable = 0x04000000; //enable interrupt
> AFMR = 0x00000001; //Disable the Acceptance filters to
> allow setup of the table
> StandardFilter[0] = 0x20012002;
> StandardFilter[1] = 0x20032004;
> GroupStdFilter[0] = 0x2009200F;
> GroupStdFilter[1] = 0x20112020;
> IndividualExtFilter[0] = 0x40010000;
> IndividualExtFilter[1] = 0x40020000;
> GroupExtFilter[0] = 0x40030000;
> GroupExtFilter[2] = 0x40040000;
> SFF_sa = 0x00000000; //Set start address of Standard table
> SFF_GRP_sa = 0x00000010; //Set start address of Standard group
> table
> EFF_sa = 0x00000018; //Set start address of Extended table
> EFF_GRP_sa = 0x00000020; //Set start address of Extended group
> table
> ENDofTable = 0x00000028; //Set end of table address
> AFMR = 0x00000000; //Enable Acceptance filters
>
> C1MOD = 0x00000000; //Release CAN controller
>
> while(1)
> {
> TX_CAN2();
> }
> }
>
> void CAN1IRQ (void) __irq
> {
>
> IOCLR1 = ~C1RDA<<8; //clear output pins
> IOSET1 = C1RDA<<8; //set output pins
> C1CMR = 0x00000004; //release the recieve buffer
> VICVectAddr = 0x00000000; //Signal the end of interrupt
> }
>
> As far as I see it, this program sends ADC values (from MCB2100
> board) via CAN2 and receives data via CAN1. But how work the
> Acceptance Filters ? Do you need them if you only have 2 CAN
> controllers (one sending, one receiving) ?
>
> Thanks in advance.
> Regards,
>
> Ronald
>>Hello Ronald,
>>
>>to get your communication working you need at least two CAN
>
> controller configured for normal
>
>>operation on your CAN bus. At the end of a CAN message there is 1-
>
> bit acknowledge gap in which each
>
>>CAN controller on the bus (which is not in listen-only mode) must
>
> send a dominant bit (0) to
>
>>acknowledge this message on the bus. If sending controller did not
>
> see this acknowledge, it will
>
>>interrupt transmission by sending a packet with a number of
>
> dominant bits, which are violating bit
>
>>stuffing rules, and is re-transmitting this packet. This procedure
>
> takes place until packet was
>
>>successfully sent on the bus (sender received an ACK) or sender
>
> falls into bus-passive mode (too
>
>>many retries) and waits until a bus-recovery condition.
>>
>>With the BTR settings you can configure the exact bit sample point
>
> and the clock synchronisation.
>
>>SJW is the synchronization jump width. It defines the number clocks
>
> which are allowed to shift
>
>>internal bit timing generator to synchronize to timing of a
>
> receiving message. TSEG1 and TSEG2
>
>>define the sample point and the number of clocks/bit. Sample is
>
> taken after TSEG1. Sample point
>
>>should be between 60..85%. In most automotive application this
>
> point is set to appr. 80%.
>
>> Sten
>>

Normal operation means that the CAN controller is setup for receiving and transmitting and is
generanting ACK to incoming messages.

To get your controller "listen" just setup for normal operation but do not transmit any messages. ;-)

I don't know exactly what this piece of code does (especailly init_CAN2() and TX_CAN2()). But
something seems to be sent while something else can be received.
You do not need acceptence filters. You can set

AFMR = 2ul;
SFF_SA = SFF_GRP_SA = EFF_SA = EFF_GRP_SA = ENDOFTAB = 0;

and you will receive all messages unfiltered.

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 Sten,

Thanks for the additional information. Well, what CANTX and CANRX do
is as follows: if you hook up 2 MCB2100 to each other using CAN you
must be able to 'change' the status of the LEDs of say board 2 with
the ADC potmeter of board 1 (and vice versa). At least that is what I
make of it ;)

And now I want to do the same, but with my own (crystal/PLL/VPBDIV)
settings and only sending my own sampled data from one uC to the
other one.

I'll have a try with your suggestion (not using the acceptance
filters). If you still have other suggestions or code examples, just
let me know :)

Thanks again for your help.
Regards,

Ronald
> Normal operation means that the CAN controller is setup for
receiving and transmitting and is
> generanting ACK to incoming messages.
>
> To get your controller "listen" just setup for normal operation but
do not transmit any messages. ;-)
>
> I don't know exactly what this piece of code does (especailly
init_CAN2() and TX_CAN2()). But
> something seems to be sent while something else can be received.
> You do not need acceptence filters. You can set
>
> AFMR = 2ul;
> SFF_SA = SFF_GRP_SA = EFF_SA = EFF_GRP_SA = ENDOFTAB = 0;
>
> and you will receive all messages unfiltered.
>
> 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 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