ID filtering on MSCAN (68HC12)

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

ID filtering on MSCAN (68HC12)

696 Views
biccius
Contributor I

Hi,

 

I have some doubts regarding the functionality of the MSCAN filter.

I have read the application note AN3034 but i cannot understand some things.

For example, into the application notes it wants to filter the ID 0x100, so why in the first line of code the constant ACC_CODE_ID100 is set to 0x2000 ?

 


/* Acceptance Code Definitions */
#define ACC_CODE_ID100 0x2000
#define ACC_CODE_ID100_HIGH ((ACC_CODE_ID100&0xFF00)>>8)
#define ACC_CODE_ID100_LOW (ACC_CODE_ID100&0x00FF)

/* Mask Code Definitions */
#define MASK_CODE_ST_ID 0x0007
#define MASK_CODE_ST_ID_HIGH ((MASK_CODE_ST_ID&0xFF00)>>8)
#define MASK_CODE_ST_ID_LOW (MASK_CODE_ST_ID&0xFF)

 

/* Acceptance Filters
CAN0IDAC = 0x10;
CAN0IDAR0 = ACC_CODE_ID100_HIGH;
CAN0IDMR0 = MASK_CODE_ST_ID_HIGH;
CAN0IDAR1 = ACC_CODE_ID100_LOW;
CAN0IDMR1 = MASK_CODE_ST_ID_LOW;
CAN0IDAC = 0x10; // Set four 16-bit Filters
CAN0IDAR2 = 0x00; // 16-bit Filter 1
CAN0IDMR2 = MASK_CODE_ST_ID_HIGH; // Accepts Standard Data Frame Msg
CAN0IDAR3 = 0x00; // with ID 0x100
CAN0IDMR3 = MASK_CODE_ST_ID_LOW;
CAN0IDAR4 = 0x00; // 16-bit Filter 2
CAN0IDMR4 = MASK_CODE_ST_ID_HIGH; // Accepts Standard Data Frame Msg
CAN0IDAR5 = 0x00; // with ID 0x100
CAN0IDMR5 = MASK_CODE_ST_ID_LOW; //
CAN0IDAR6 = 0x00; // 16-bit Filter 3
CAN0IDMR6 = MASK_CODE_ST_ID_HIGH; // Accepts Standard Data Frame Msg
CAN0IDAR7 = 0x00; // with ID 0x100
CAN0IDMR7 = MASK_CODE_ST_ID_LOW; */

 

Another question: it's possibile to set a range od IDs to filter? For example i want to see only the messages between IDs 0x01E4 and 0x02E4.

Labels (1)
0 Kudos
1 Reply

282 Views
kef
Specialist I
  • For example, into the application notes it wants to filter the ID 0x100, so why in the
  • first line of code the constant ACC_CODE_ID100 is set to 0x2000 ?

You need to find two figures in your datasheet. One is called like Standard Identifier Mapping (for 11bit ID messagees) and another one like Extended Identifier Mapping (for 29bit ID messages). As you may see in Standard ID mepping, bit0 of ID, ID0 is placed not in bit0 of IDR1 register, but in bit5 of IDR1. Identifier mapping is the same for receuve buffer (CANxRIDRx registers), trasmin buffers (CANxTIDRx registers), and also the same for filter acceptance and mask registers. In the case of standard identifiers, ACC_CODE_ID100 is (0x100<<5)=0x2000. For extended 29bit identifiers it is more complicated. As you may see in AN code, ACC_CODE_ID100 is sperated into high and low part and directly applied to IDAR and IDAM registers, whithout any shifting.

 

 

 

  • Another question: it's possibile to set a range od IDs to filter? For example i want to see only
  • the messages between *IDs 0x01E4 and 0x02E4.
0 Kudos