EasyManuals Logo

Microchip Technology dsPIC33 series User Manual

Microchip Technology dsPIC33 series
116 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #75 background imageLoading...
Page #75 background image
2018 Microchip Technology Inc. DS70005340A-page 75
CAN FD Protocol Module
Example 6-1: Message Transmission Code Example (Continued)
/* Get the address of the message buffer to write to. Load the buffer and then set the UINC bit.
Set the TXREQ bit next to send the message. */
CANFD_TX_MSGOBJ *txObj;
/* Transmit message from TXQ - CANFD base frame with BRS*/
/* SID = 0x100, 64 bytes of data */
txObj = (CANFD_TX_MSGOBJ *)C1TXQUAL;
txObj->bF.id.SID = 0x100;
txObj->bF.id.EID = 0x0000;
txObj->bF.ctrl.BRS = 1 ; //Switch bit rate
txObj->bF.ctrl.DLC = 0xF; //64 bytes
txObj->bF.ctrl.FDF = 1; // CANFD frame
txObj->bF.ctrl.IDE = 0; //Standard frame
for (index=0;index<0x40;index++ )
{
txObj->byte[index+8] = 0x5A ; // 64 bytes of 0x5A
}
C1TXQCONLbits.UINC = 1; // Set UINC bit
C1TXQCONLbits.TXREQ = 1; // Set TXREQ bit
/* Transmit message 0 from FIFO 1 - CANFD base frame with BRS*/
/* SID = 0x300 , 16 bytes of data */
txObj = (CANFD_TX_MSGOBJ *)C1FIFOUA1L;
txObj->bF.id.SID = 0x300;
txObj->bF.id.EID = 0x0000;
txObj->bF.ctrl.BRS = 1 ; //Switch bit rate
txObj->bF.ctrl.DLC = 0xA; //16 bytes
txObj->bF.ctrl.FDF = 1; // CANFD frame
txObj->bF.ctrl.IDE = 0; //Standard frame
for (index=0;index<0x10;index++ )
{
txObj->byte[index+8] = 0xA5 ; // 16 bytes of 0xA5
}
C1FIFOCON1Lbits.UINC = 1; // Set UINC bit
C1FIFOCON1Lbits.TXREQ = 1; // Set TXREQ bit
/* Transmit message 1 from FIFO 1 - CANFD base frame with BRS*/
/* SID = 0x500, EID = 0xC000, 12 bytes of data */
txObj = (CANFD_TX_MSGOBJ *)C1FIFOUA1L;
txObj->bF.id.SID = 0x500;
txObj->bF.id.EID = 0xC000;
txObj->bF.ctrl.BRS = 1 ; //Switch bit rate
txObj->bF.ctrl.DLC = 0x9; //12 bytes
txObj->bF.ctrl.FDF = 1; // CANFD frame
txObj->bF.ctrl.IDE = 0; //Standard frame
for (index=0;index<0xC;index++ )
{
txObj->byte[index+8] = 0x55 ; // 12 bytes of 0x55
}
C1FIFOCON1Lbits.UINC = 1; // Set UINC bit
C1FIFOCON1Lbits.TXREQ = 1; // Set TXREQ bit
while(1);
}

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Microchip Technology dsPIC33 series and is the answer not in the manual?

Microchip Technology dsPIC33 series Specifications

General IconGeneral
BrandMicrochip Technology
ModeldsPIC33 series
CategoryMotherboard
LanguageEnglish

Related product manuals