Hardware Reference
In-Depth Information
CAN1IDMR1 5 0x00;
/* “ */
CAN1IDMR2 5 0x3F;
/* “ */
CAN1IDMR3 5 0xFF;
/* “ */
CAN1IDAR4 5 0x50;
/* set acceptance identifier P1 */
CAN1IDAR5 5 0x3C;
/* “ */
CAN1IDAR6 5 0x40;
/* “ */
CAN1IDAR7 5 0x00;
/* “ */
CAN1IDMR4 5 0x00;
/* acceptance mask for P1 */
CAN1IDMR5 5 0x00;
/* “ */
CAN1IDMR6 5 0x3F;
/* “ */
CAN1IDMR7 5 0xFF;
/* “ */
CAN1IDAC
5 0x00;
/* select two 32-bit filter mode */
CAN1CTL0
5 0x25;
/* stop clock on wait mode, enable wake-up */
CAN1CTL0 & 5 , INITRQ;
/* exit initialization mode *
}
The MSCAN application can be very complicated; the initial configuration of the MSCAN
may need to be changed to satisfy the changing environment. The following example illustrates
the change of acceptance filters:
Example 13.4
Write an instruction sequence to change the configuration of the CAN1 module so that it
will accept messages with a standard identifier starting with letter T or P.
Solution: The procedure described in Section 13.9.8 should be followed to reconfigure the CAN1
module. In this example, we set up two sets of identical acceptance filters to accept standard
identifiers that start with letters T and P. The instruction sequence that performs the reconfigu-
ration is as follows:
ct1
brset CAN1TFLG,$07,tb_empty
; wait until all transmit buffers are empty
bra ct1
tb_empty bset CAN1CTL0,SLPRQ
; request to enter sleep mode
ct2 brclr CAN1CTL1,SLPAK,ct2
; wait until sleep mode is entered
bset CAN1CTL0,INITRQ
; request to enter initialization mode
ct3
brclr CAN1CTL1,INITAK,ct3
; wait until initialization mode is entered
movb #$10,CAN1IDAC
; select four 16-bit acceptance mode
movb #$54,CAN1IDAR0
; set up filter for letter T for standard
movb
#0,CAN1IDAR1
; identifier
movb #$50,CAN1IDAR2
; set up filter for letter P for standard
clr
CAN1IDAR3
; identifier
clr
CAN1IDMR0
; acceptance mask for T
movb
#$F7,CAN1IDMR1
; check IDE bit only (0 for standard identifier)
clr
CAN1IDMR2
; acceptance mask for P
movb #$F7,CAN1IDMR3
; check IDE bit only (must be 0)
movb #$54,CAN1IDAR4
; set up filter for letter T for standard
movb
#0,CAN1IDAR5
; identifier
movb #$50,CAN1IDAR6
; set up filter for letter P for standard
clr
CAN1IDAR7
; identifier
clr
CAN1IDMR4
; acceptance mask for T
 
Search WWH ::




Custom Search