English
Language : 

70353C Datasheet, PDF (47/76 Pages) Microchip Technology – Section 21. Enhanced Controller Area Network
Section 21. Enhanced Controller Area Network (ECAN™)
Example 21-4: Code Example for Filtering Standard Data Frame (Continued)
/* Select Acceptance Filter Mask 0 for Acceptance Filter 0 */
C1FMSKSEL1bits.F0MSK=0x0;
/* Configure Acceptance Filter Mask 0 register to mask SID<2:0>
* Mask Bits (11-bits) : 0b111 1111 1000 */
C1RXM0SIDbits.SID = 0x7F8;
/* Configure Acceptance Filter 0 to match standard identifier
Filter Bits (11-bits): 0b011 1010 xxx with the mask setting, message with SID
range 0x1D0-0x1D7 will be accepted by the ECAN module. */
C1RXF0SIDbits.SID = 0x01D0;
/* Acceptance Filter 0 to check for Standard Identifier */
C1RXM0SIDbits.MIDE = 0x1;
C1RXF0SIDbits.EXIDE= 0x0;
/* Acceptance Filter 0 to use Message Buffer 10 to store message */
C1BUFPNT1bits.F0BP = 0xA;
/* Filter 0 enabled for Identifier match with incoming message */
C1FEN1bits.FLTEN0=0x1;
/* Clear Window Bit to Access ECAN
* Control Registers */
C1CTRL1bits.WIN=0x0;
/* Place the ECAN module in normal
* mode. */
C1CTRL1bits.REQOP = 0;
while(C1CTRL1bits.OPMODE != 0);
/* The following code shows one example of how the application can wait
for a message to be received in message buffer 10 */
while(1)
{
/* Message was received. */
while (C1RXFUL1bits.RXFUL10 == 0);
C1RXFUL1bits.RXFUL10 = 0;
}
}
A code example used to configure acceptance filter 2 to receive EID messages using the
acceptance filter mask register to mask EID<5:0> bits is shown in Example 21-5.
21
© 2008-2011 Microchip Technology Inc.
DS70353C-page 21-47