EasyManua.ls Logo

Microchip Technology dsPIC33 series - Page 78

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
Loading...
dsPIC33/PIC24 Family Reference Manual
DS70005340A-page 78 2018 Microchip Technology Inc.
7.2 Transmit Event FIFO Code Example
A code example to save the transmitted messages using TEF is shown in Example 7-1.
Example 7-1: Using the Transmit Event FIFO Code
#include <xc.h>
/* This code example demonstrates a method to configure the CAN FD module to save the transmitted
messages in the TEF. This example uses CAN1, FIFO1 and TEF */
/* Include fuse configuration code here. */
#define MAX_WORDS 100
unsigned
int __attribute__((aligned(4)))CanTxBuffer[MAX_WORDS];
//message buffer to be written
unsigned int * currentMessageBuffer; //
Points to message buffer to be read
/*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;
/* CAN TX Message Object*/
typedef union _CANFD_TX_MSGOBJ {
struct {
CANFD_MSGOBJ_ID id;
CANFD_TX_MSGOBJ_CTRL ctrl;
CANFD_MSG_TIMESTAMP timeStamp;
} bF;
unsigned int word[4];
unsigned char byte[8];
} CANFD_TX_MSGOBJ;
/* CANFD TEF Message Object */
typedef union _CAN_TEF_MSGOBJ {
struct {
CANFD_MSGOBJ_ID id;
CANFD_TX_MSGOBJ_CTRL ctrl;
CANFD_MSG_TIMESTAMP timeStamp;
} bF;
unsigned int word[4];
} CANFD_TEF_MSGOBJ;

Related product manuals