How to use the Acceptance Filter MSCAN of MC9S12ZVC?

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

How to use the Acceptance Filter MSCAN of MC9S12ZVC?

1,697 Views
seung-taeryu
Contributor II

Hello. My name is Ryu.

I'd like to know how to use the acceptance filter of MSCAN.

 

 

I use standard id 0x1F0 ~ 0x1F4, 0x5FA ~ 0x5FC.

And Below Functions are generated by PE.

 

SetAcceptanceMode(byte Mode);

SetAcceptanceCode(dword AccCode1, dword AccCode2);

SetAcceptanceCode(dword AccCode1, dword AccCode2);

 

Please let me know how to set the Acceptance Filter using these functions.

Labels (1)
0 Kudos
3 Replies

1,080 Views
gordonp
Contributor III

Hi Radek

I seem to have a problem understanding how to implement acceptance masks for extended IDs. I have a project that needs to respond only to message ID 0x0FF0001 and 0x0FF0002. I would be grateful if you could show me how to achieve this.

Regards

Gordon

0 Kudos

1,080 Views
RadekS
NXP Employee
NXP Employee

Hi Gordon,

please look at document CAN Standard ID and CAN Extended ID for S12(X) and MagniV devices, memories refreshment 

Since you need filtering extended ID, please look at EXTENDED ID sheet.

Some more details regarding MSCAN module you may get from AN3034 Using MSCAN on the HCS12 Family, SW


I hope it helps you

Have a great day,
Radek

1,080 Views
RadekS
NXP Employee
NXP Employee

Hi Seung-Tang,

I suppose that you mean functions:

SetAcceptanceMode(byte Mode);

SetAcceptanceCode(dword AccCode1, dword AccCode2);

SetAcceptanceMask(dword AccMask1, dword AccMask2);

In fact, these functions just write Mode, AccCode1, AccCode2, AccMask1 and AccMask2 values into appropriate CANIDAC_IDAM, CANIDARx and CANIDMRx registers.

Since you use standard ID (11bit ID), you could define up to 4 16bit filters (or up to 8 8bit filters).

Note: The bit IDE=0 in the case of standard IDs.

I will focus now only on 16bit filter mode – Mode=0x01

When we will write your IDs as binary, we could see that four 16bit filters will be enough and simultaneously you will also filter-out all other IDs.

0x1F0  -> 001 1111 0000

0x1F1  -> 001 1111 0001

0x1F2  -> 001 1111 0010

0x1F3  -> 001 1111 0011

The first filter will be 001 1111 00XX = 0011 1110 0XX0 0000 after left alignment -> 0x3E00 (0x3E10 in the case of Remote frame) as ID and 0x0067 (0x0077 if we do not care whether it is Data or Remote frame) as mask.

Note: We do not care about the last three bits in 16bit filter

CANIDAR1 =0x3E, CANIDAR0 =0x00, CANIDMR1 =0x00, CANIDMR0 =0x67

0x1F4  -> 001 1111 0100

The second filter will be 001 1111 0100 = 0011 1110 1000 0000 after left alignment -> 0x3E80 (0x3E90 in the case of Remote frame) as ID and 0x0007 (0x0017 if we do not care whether it is Data or Remote frame) mask.

CANIDAR3 =0x3E, CANIDAR2 =0x00, CANIDMR3 =0x00, CANIDMR2 =0x07

0x5FA  -> 101 1111 1010

0x5FB  -> 101 1111 1011

The third filter will be 101 1111 101X = 1011 1111 01X0 0000 after left alignment -> 0xBF40 (0xBF50 in the case of Remote frame) as ID and 0x0027 (0x0037 if we do not care whether it is Data or Remote frame) mask.

CANIDAR5 =0xBF, CANIDAR4 =0x40, CANIDMR5 =0x00, CANIDMR4 =0x27

0x5FC  -> 101 1111 1100

The fourth filter will be 101 1111 1100 = 1011 1111 1000 0000 after left alignment -> 0xBF80 (0xBF90 in the case of Remote frame) as ID and 0x0007 (0x0017 if we do not care whether it is Data or Remote frame) mask.

CANIDAR7 =0xBF, CANIDAR6 =0x80, CANIDMR7 =0x00, CANIDMR6 =0x07

The AccCode1,2 and AccMask1,2 types are defined as:

typedef union {

          dword dw;

          struct {

            byte b0;

            byte b1;

            byte b2;

            byte b3;

          }b;

        }DwordSwap;

Therefore the AccCode1 should be 0x003E003E, AccCode2 should be 0x40BF80BF, AccMask1 should be 0x67000700 and AccMask2 should be 0x27000700.

I hope that I didn’t make any mistake in my calculations.

Please check it.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos