2018 Microchip Technology Inc. DS70005340A-page 73
CAN FD Protocol Module
6.14 Resetting Transmit FIFO
A Transmit FIFO can be reset by:
• Setting FRESET (C1FIFOCONxL<10>) or
• Placing the module in Configuration mode (OPMOD<2:0> = 100)
Resetting the FIFO will reset the Head and Tail Pointers, and the C1FIFOSTAx register. The
settings in the C1FIFOCONxL and C1FIFOCONxH registers will not change.
Before resetting a TX FIFO using FRESET, ensure no transmissions are pending.
6.15 Resetting Transmit Queue
The Transmit Queue can be reset by:
• Setting FRESET (C1TXQCONL<10>) or
• Placing the module in Configuration mode (OPMOD<2:0> = 100)
Resetting the TXQ will reset the Head and Tail Pointers, and the C1TXQSTA register. The
settings in the C1TXQCONL and C1TXQCONH registers will not change.
Before resetting the TXQ using FRESET, ensure no transmissions are pending.
6.16 Message Transmission Code Example
Example 6-1: Message Transmission Code
#include <xc.h>
/* This code example demonstrates a method to configure the CAN FD module to transmit Standard and
Extended ID CAN FD messages. This uses CAN1, TXQ and FIFO1. TXQ size is 1 and FIFO1 size is 2. */
/* Include fuse configuration code here. */
#define MAX_WORDS 100
unsigned int __attribute__((aligned(4)))CanTxBuffer[MAX_WORDS];
/*Data structure to implement a CANFD message buffer. */
/* CANFD Message Time Stamp */
typedef unsigned long CANFD_MSG_TIMESTAMP;
/* CAN TX Message Object Control*/
typedef struct _CANFD_TX_MSGOBJ_CTRL {
unsigned DLC:4;
unsigned IDE:1;
unsigned RTR:1;
unsigned BRS:1;
unsigned FDF:1;
unsigned ESI:1;
unsigned SEQ:7;
unsigned unimplemented1:16;
} CANFD_TX_MSGOBJ_CTRL;
/* CANFD TX Message ID*/
typedef struct _CANFD_MSGOBJ_ID {
unsigned SID:11;
unsigned long EID:18;
unsigned SID11:1;
unsigned unimplemented1:2;
} CANFD_MSGOBJ_ID;