English
Language : 

70353C Datasheet, PDF (58/76 Pages) Microchip Technology – Section 21. Enhanced Controller Area Network
dsPIC33E/PIC24E Family Reference Manual
21.8.2 DMA Operation for Receiving Data
When the ECAN controller completes a received message (eight words), the completed
message is transferred to a message buffer in device RAM by the DMA module. The ECAN
module generates a receive data interrupt to start a DMA cycle. In response to this interrupt, the
DMA channel that is configured for ECAN message reception reads from the ECAN Receive
Data register (CiRXD) and stores the message in the device RAM buffer. Eight words are
transferred for every message that is received by the ECAN controller. The detailed layout of the
received message is provided in 21.2 “CAN Message Formats”. A sample code for configuring
the DMA channel for ECAN1 reception is shown in Example 21-7.
Example 21-7: DMA Channel 1 Configuration for ECAN1 Reception
/* This code snippet shows an example of configuring a DMA channel for the
ECAN message reception. Refer to Example 21-4 for an application example */
/* Data Transfer Size: Word Transfer Mode */
DMA1CONbits.SIZE = 0x0;
/* Data Transfer Direction: Peripheral to device RAM */
DMA1CONbits.DIR = 0x0;
/* DMA Addressing Mode: Peripheral Indirect Addressing mode */
DMA1CONbits.AMODE = 0x2;
/* Operating Mode: Continuous, Ping-Pong modes disabled */
DMA1CONbits.MODE = 0x0;
/* Assign ECAN1 Receive event for DMA Channel 0 */
DMA1REQ = 34;
/* Set Number of DMA Transfer per ECAN message to 8 words */
DMA1CNT = 7;
/* Peripheral Address: ECAN1 Receive Register */
DMA1PAD = (volatile unsigned int) &C1RXD;
.
.
.
.
unsigned long address;
DMA1STAL = (unsigned int) &ecan1msgBuf;
DMA1STAH = (unsigned int) &ecan1msgBuf;
/* Channel Enable: Enable DMA Channel 1 */
DMA1CONbits.CHEN = 0x1;
/* Channel Interrupt Enable: Enable DMA Channel 1 Interrupt */
IEC0bits.DMA1IE = 1;
Note: For more information on how to configure the DMA Controller, refer to Section 22.
“Direct Memory Access (DMA)” (DS70348).
DS70353C-page 21-58
© 2008-2011 Microchip Technology Inc.