setting identifier acceptance filter for MSCAN

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

setting identifier acceptance filter for MSCAN

2,961 Views
hasaur
Contributor II

Hello,

I wonder if I am understanding the setting of identifier acceptance filter for MSCAN.

I have a MC9S08DZ128 and I would like to set 4 filters of 16bits.

 

How should I think to set mask and code ?

I have made 4 different codes with their mask : for example :

I would like to filter ID of 0x1A1 :

CANIDAR0 = 0x34;

CANIDAR1 = 0x20;

CANIDMR0 =0x00;

CANIDMR1 = 0x07;

It works fine. But when I want to set another filter (CANIDAR2 and CANIDAR3 with CANIDMR2 and CANIDMR3), it doesn't work.

How do filters work ? I should I do to set 4 filters ?

 

Thank you in advance for your answers.

Labels (1)
0 Kudos
Reply
4 Replies

922 Views
kef
Specialist I

Yes, your filter setup should pass messages with id = 0x1A1. What was not mentioned is that filter will pass only standard 11-bits message with id=0x1A1, and only if it is non-RTR message.

 

You should look for a while at datasheet figures 12-23 Extended Identifier Mapping and 12-24 Standard Identifier Mapping. Filter IDAR and IDAM registers, also receive and transmit buffer identifier registers IDR0-IDR3 have the same bits mapping. IDE bit in xxxIDR1 register determines identifier mapping scheme. IDE=1 means 29-bits identifier, IDE=0 -  11-bits identifier.

 

If you get that logic, 16-bits filter setup for standard only id=0x1A1, but both RTR and non RTR should be this:

 

CANIDAR0 = 0x34;

CANIDAR1 = 0x20;

CANIDMR0 =0x00;

CANIDMR1 = 0x17;

 

32-bits filter setup for extended only identifier 0x1A1, both RTR and non RTR should be this:

CANIDAR0 = 0;

CANIDAR1 = 0x18;

CANIDAR2 =0x3;

CANIDAR3 = 0x42;

CANIDMR0 = 0;

CANIDMR1 = 0;

CANIDMR2 = 0;

CANIDMR3 = 1;

 

To ease setup a bit, for standard id you may you use something like this:

CANIDAR0 = id >> 3;

CANIDAR1 = id << 5;

 

extended id:

CANIDAR0 = id >> 21;

CANIDAR1 = ((id >> (18-5)) & 0xE0) | 0x18|((id >> 15) & 7);

CANIDAR2 = id >> 7;

CANIDAR3 = id << 1;

0 Kudos
Reply

922 Views
hasaur
Contributor II

Hello and thank you for your help.

I only have standard identifier and non-RTR.

The thing that I don't understand is that I can configure 2 filters with CANIDAR0-CANIDAR1/CANIDMR0-CANIDMR1 and CANIDAR4-CANIDAR5/CANIDMR4-CANIDMR5 : that wors very well. The other filters (configured with CANIDAR2-CANIDAR3/CANIDMR2-CANIDMR3 and CANIDAR6-CANIDAR7/CANIDMR6-CANIDMR7) are never applied to messages.

0 Kudos
Reply

922 Views
kef
Specialist I

Maybe acceptance mode is not setup well? Can you read and confirm that CANIDAC IDAM1:IDAM0 bits ==01? If not, then do you setup CANIDAC bits while in initialization mode? I don't know why 2nd and 4th 16-bits filters aren't working for you. I hope it's not S08DZ errata. I'm waiting for S08DZ board and don't have time to modify MSCAN driver.

0 Kudos
Reply

922 Views
hasaur
Contributor II

Please if somebody has already set 4 filters of 16 bits for the MSCAN...

0 Kudos
Reply