English
Language : 

70353C Datasheet, PDF (42/76 Pages) Microchip Technology – Section 21. Enhanced Controller Area Network
dsPIC33E/PIC24E Family Reference Manual
Example 21-3: Code Example for Transmitting Extended Remote Frame (Continued)
/* Configure Message Buffer 2 for Transmission and assign priority */
C1TR23CONbits.TXEN2 = 0x1;
C1TR23CONbits.TX2PRI = 0x3;
/* At this point the ECAN1 module is ready to transmit a message. Place the ECAN module
in Normal mode. */
C1CTRL1bits.REQOP = 0;
while(C1CTRL1bits.OPMODE != 0);
/* Write to message buffer 2*/
/* CiTRBnSID = 0bxxx1 0010 0011 1101
IDE = 0b1
SRR = 0b1
SID<10:0> : 0b100 1000 1111 */
ecan1MsgBuf[2][0] = 0x123F;
/* CiTRBnEID = 0bxxxx 1111 0000 0000
EID<17:6> = 0b1111 0000 0000 */
ecan1MsgBuf[2][1] = 0x0F00;
/* CiTRBnDLC = 0b0000 1100 xxx0 1111
EID<17:6> = 0b000011
RTR = 0b1
RB1 = 0b0
RB0 = 0b0
DLC = 0b1000 */
/* RTR bit is set */
ecan1MsgBuf[2][2] = 0x0E00;
/* An RTR message does not have a data payload. */
/* Request message buffer 2 transmission */
C1TR23CONbits.TXREQ2 = 0x1;
/* The following shows an example of how the TXREQ bit can be polled to check if
transmission is complete. */
while(C1TR23CONbits.TXREQ2 == 1);
/* Message was placed successfully on the bus */
while(1);
}
DS70353C-page 21-42
© 2008-2011 Microchip Technology Inc.