EmbeddedRelated.com
Forums

Problem in setting CAN ID filter

Started by folg...@yahoo.com March 11, 2009
Hello,

I have a problem with setting the CAN ID filter. I use four 16 bit filter. I want to set one filter now.

CAN0IDMR0 = 0xFF;
CAN0IDAR0 = 0x00;
CAN0IDMR1 = 0x18;
CAN0IDAR1 = 0x08;
CAN0IDMR2 = 0x00;
CAN0IDAR2 = 0x00;
CAN0IDMR3 = 0x00;
CAN0IDAR3 = 0x00;
CAN0IDMR4 = 0x00;
CAN0IDAR4 = 0x00;
CAN0IDMR5 = 0x00;
CAN0IDAR5 = 0x00;
CAN0IDMR6 = 0x00;
CAN0IDAR6 = 0x00;
CAN0IDMR7 = 0x00;
CAN0IDAR7 = 0x00;
CAN0IDAC |= 0x01;

I want that only messages with ID 001 can be received. But it does not work. I can receive messages with ID 000 but not with 001. I had a look at the manual but I do not know what I am doing wrong. Perhaps someone can tell me.

Thank you very much.

Best regards

Hello,

Inorder to receive only message with CAN ID "0x001", set the Mask and Acceptance registers as shown below.

CAN0IDMR0 = 0x00;
CAN0IDMR1 = 0x00;

CAN0IDAR0 = 0x00;
CAN0IDAR2 = 0x20;

Try the above settings, I hope this helps you./..


regards
Yadunandan Kasu(Nandu)

--- On Wed, 11/3/09, f...@yahoo.com wrote:
From: f...@yahoo.com
Subject: [68HC12] Problem in setting CAN ID filter
To: 6...
Date: Wednesday, 11 March, 2009, 9:30 PM

Hello,

I have a problem with setting the CAN ID filter. I use four 16 bit filter. I want to set one filter now.

CAN0IDMR0 = 0xFF;
CAN0IDAR0 = 0x00;
CAN0IDMR1 = 0x18;
CAN0IDAR1 = 0x08;
CAN0IDMR2 = 0x00;
CAN0IDAR2 = 0x00;
CAN0IDMR3 = 0x00;
CAN0IDAR3 = 0x00;
CAN0IDMR4 = 0x00;
CAN0IDAR4 = 0x00;
CAN0IDMR5 = 0x00;
CAN0IDAR5 = 0x00;
CAN0IDMR6 = 0x00;
CAN0IDAR6 = 0x00;
CAN0IDMR7 = 0x00;
CAN0IDAR7 = 0x00;
CAN0IDAC |= 0x01;

I want that only messages with ID 001 can be received. But it does not work.. I can receive messages with ID 000 but not with 001. I had a look at the manual but I do not know what I am doing wrong. Perhaps someone can tell me..

Thank you very much.

Best regards

Cricket on your mind? Visit the ultimate cricket website. Enter http://beta.cricket.yahoo.com



> Hello,

> Inorder to receive only message with CAN ID "0x001", set the Mask and
> Acceptance registers as shown below.

> CAN0IDMR0 = 0x00;
> CAN0IDMR1 = 0x00;

> CAN0IDAR0 = 0x00;
> CAN0IDAR2 = 0x20;

> Try the above settings, I hope this helps you./..

Hello,

I tried the settings but it does not work. Has anybody another idea. I had a look at the manual but I do not know what I am doing wrong. Perhaps someone could explain the structure of the filters to me, which bits are important for the different filters and so on.

Best regards

Hi,

1. Are you writing "0xFF" to any of the mask registers i.e. CAN0IDMR0~7 ?? you should not write the value of "0xFF"to these registers in your case.

2. What value are setting to the register "CAN0IDAC" ?? It is recommended to set the value of "0x10", if you are using Standard message format. (i.e. message with 11-bit CAN ID)

Try the above settings and check. If it doesnt work.. then I think may be the problem is in your code.


regards
Yadunandan Kasu(Nandu)

--- On Fri, 20/3/09, f...@yahoo.com wrote:
From: f...@yahoo.com
Subject: [68HC12] Re: Problem in setting CAN ID filter
To: 6...
Date: Friday, 20 March, 2009, 1:08 AM

> Hello,

> Inorder to receive only message with CAN ID "0x001", set the Mask and
> Acceptance registers as shown below.

> CAN0IDMR0 = 0x00;
> CAN0IDMR1 = 0x00;

> CAN0IDAR0 = 0x00;
> CAN0IDAR2 = 0x20;

> Try the above settings, I hope this helps you./..

Hello,

I tried the settings but it does not work. Has anybody another idea. I had a look at the manual but I do not know what I am doing wrong. Perhaps someone could explain the structure of the filters to me, which bits are important for the different filters and so on.

Best regards

Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/



Hello,

here are parts of my code:

typedef struct
{
unsigned int IDAC;
unsigned int CANidar0;
unsigned int CANidmr0;
unsigned int CANidar1;
unsigned int CANidmr1;
unsigned int CANidar2;
unsigned int CANidmr2;
unsigned int CANidar3;
unsigned int CANidmr3;
unsigned int CANidar4;
unsigned int CANidmr4;
unsigned int CANidar5;
unsigned int CANidmr5;
unsigned int CANidar6;
unsigned int CANidmr6;
unsigned int CANidar7;
unsigned int CANidmr7;
}FILTER;

FILTER stFilter {
0x10, // IDAC
0x00, 0x00, // (CANidar0, CANidmr0)
0x00, 0x00, // (CANidar1, CANidmr1)
0x20, 0x00, // (CANidar2, CANidmr2)
0x00, 0x00, // (CANidar3, CANidmr3)
0x00, 0x00, // (CANidar4, CANidmr4)
0x00, 0x00, // (CANidar5, CANidmr5)
0x00, 0x00, // (CANidar6, CANidmr6)
0x00, 0x00 // (CANidar7, CANidmr7)
};
Filter(stFilter);
char Filter(FILTER fi)
{
CAN0IDAC |= acfi.IDAC;

CAN0IDMR0 = acfi.CANidmr0;
CAN0IDAR0 = fi.CANidar0;
CAN0IDMR1 = fi.CANidmr1;
CAN0IDAR1 = fi.CANidar1;
CAN0IDMR2 = fi.CANidmr2;
CAN0IDAR2 = fi.CANidar2;
CAN0IDMR3 = fi.CANidmr3;
CAN0IDAR3 = fi.CANidar3;
CAN0IDMR4 = fi.CANidmr4;
CAN0IDAR4 = fi.CANidar4;
CAN0IDMR5 = fi.CANidmr5;
CAN0IDAR5 = fi.CANidar5;
CAN0IDMR6 = fi.CANidmr6;
CAN0IDAR6 = fi.CANidar6;
CAN0IDMR7 = fi.CANidmr7;
CAN0IDAR7 = fi.CANidar7;
}
But it does not work. I am only able to receive messages with ID 0x000. For example 0x001 or 0x002 do not work.

Best regards

To ignore ID bits, corresponding DMR bits should be set to '1'. You have all
DMR's set to all zeros.
When DMRx bit is zero, then corrsponding IDRx bit should match corrsponding
DARx bit, else message won't pass.
To accept all messages simply set all DMR bits to ones.

If your code receives standard id messages with id 0, then it should receive
also 0x100. In 4x16bit filters mode (IDAC = 0x10), idar2 and idar3 form
16bit filter. If you check message buffer layout (look in datasheets for
figures Receive / Transmit Message Buffer Standard Identifier and the same
for Extended Identifier), then you should find that 0x20 in IDR0 and 0 in
IDR1 means message ID = ((0x20<<8) | 0x00) >> 5 = 0x100.

Edward

----- Original Message -----
From:
To: <6...>
Sent: Friday, March 20, 2009 16:23
Subject: [68HC12] Re: Problem in setting CAN ID filter
> Hello,
>
> here are parts of my code:
>
> typedef struct
> {
> unsigned int IDAC;
> unsigned int CANidar0;
> unsigned int CANidmr0;
> unsigned int CANidar1;
> unsigned int CANidmr1;
> unsigned int CANidar2;
> unsigned int CANidmr2;
> unsigned int CANidar3;
> unsigned int CANidmr3;
> unsigned int CANidar4;
> unsigned int CANidmr4;
> unsigned int CANidar5;
> unsigned int CANidmr5;
> unsigned int CANidar6;
> unsigned int CANidmr6;
> unsigned int CANidar7;
> unsigned int CANidmr7;
> }FILTER;
>
> FILTER stFilter> {
> 0x10, // IDAC
> 0x00, 0x00, // (CANidar0, CANidmr0)
> 0x00, 0x00, // (CANidar1, CANidmr1)
> 0x20, 0x00, // (CANidar2, CANidmr2)
> 0x00, 0x00, // (CANidar3, CANidmr3)
> 0x00, 0x00, // (CANidar4, CANidmr4)
> 0x00, 0x00, // (CANidar5, CANidmr5)
> 0x00, 0x00, // (CANidar6, CANidmr6)
> 0x00, 0x00 // (CANidar7, CANidmr7)
> };
> Filter(stFilter);
> char Filter(FILTER fi)
> {
> CAN0IDAC |= acfi.IDAC;
>
> CAN0IDMR0 = acfi.CANidmr0;
> CAN0IDAR0 = fi.CANidar0;
> CAN0IDMR1 = fi.CANidmr1;
> CAN0IDAR1 = fi.CANidar1;
> CAN0IDMR2 = fi.CANidmr2;
> CAN0IDAR2 = fi.CANidar2;
> CAN0IDMR3 = fi.CANidmr3;
> CAN0IDAR3 = fi.CANidar3;
> CAN0IDMR4 = fi.CANidmr4;
> CAN0IDAR4 = fi.CANidar4;
> CAN0IDMR5 = fi.CANidmr5;
> CAN0IDAR5 = fi.CANidar5;
> CAN0IDMR6 = fi.CANidmr6;
> CAN0IDAR6 = fi.CANidar6;
> CAN0IDMR7 = fi.CANidmr7;
> CAN0IDAR7 = fi.CANidar7;
> }
> But it does not work. I am only able to receive messages with ID 0x000.
> For example 0x001 or 0x002 do not work.
>
> Best regards
>
>
Hello,

thank you very much for the detailed explication!

Best regards