I've been working for a few days now to get code working that reads from CAN via DMA. I've not been successful getting DMA to read from the IF3 register. 5305.HercCANDMA.zip
I've attached the full CCS project for my last attempt. I have gotten a working version that uses CAN1 in loopback mode and reads the transmitted data using the IF3 data. But I wasn't able to make the leap to getting DMA working. Here's the details in case someone can see the error. When I run this, it doesn't appear that anything is copied via DMA.
void main(void) { /* USER CODE BEGIN (3) */ initData(); /* enable irq interrupt in */ _enable_IRQ_interrupt_(); /* - configuring dma control packets */ g_dmaCTRLPKT1.SADD = (uint32) &(canREG1->IF3DATx[0]); /* source address */ g_dmaCTRLPKT1.DADD = (uint32) rx_data; /* destination address */ g_dmaCTRLPKT1.CHCTRL = 0; /* channel control */ g_dmaCTRLPKT1.FRCNT = 1; /* frame count */ g_dmaCTRLPKT1.ELCNT = 1; /* element count */ g_dmaCTRLPKT1.ELDOFFSET = 0; /* element destination offset */ g_dmaCTRLPKT1.ELSOFFSET = 0; /* element source offset */ g_dmaCTRLPKT1.FRDOFFSET = 0; /* frame destination offset */ g_dmaCTRLPKT1.FRSOFFSET = 0; /* frame source offset */ g_dmaCTRLPKT1.PORTASGN = PORTB_READ_PORTA_WRITE; g_dmaCTRLPKT1.RDSIZE = ACCESS_64_BIT; /* read size */ g_dmaCTRLPKT1.WRSIZE = ACCESS_64_BIT; /* write size */ g_dmaCTRLPKT1.TTYPE = FRAME_TRANSFER; /* transfer type */ g_dmaCTRLPKT1.ADDMODERD = ADDR_FIXED; /* address mode read */ g_dmaCTRLPKT1.ADDMODEWR = ADDR_FIXED; /* address mode write */ g_dmaCTRLPKT1.AUTOINIT = AUTOINIT_OFF; /* autoinit */ canInit(); canEnableloopback(canREG1, Internal_Lbk); // Read DATA A & B - 8 bytes */ canREG1->IF3OBS = 0x18; // Message box 2 configured for auto update canREG1->IF3UEy[0] = 0x00000002; // Enable DMA REquest line for IF3 canREG1->CTL |= 0x100000U; /* - DMA Configuration */ /* Enable Interrupt after reception of data */ dmaEnableInterrupt(DMA_CH0, FTC, DMA_INTA); dmaEnableInterrupt(DMA_CH0, LFS, DMA_INTA); // Assign CAN1 IF3 dmaReqAssign(DMA_CH0, DMA_REQ16); /* - setting dma control packets */ dmaSetCtrlPacket(DMA_CH0, g_dmaCTRLPKT1); /* - setting the dma channel to trigger on h/w request */ dmaSetChEnable(DMA_CH0, DMA_HW); /* Enable DMA */ dmaEnable(); for (int i = 0; i < D_COUNT; i += 8) { canTransmit(canREG1, canMESSAGE_BOX1, (const uint8 *) &tx_data[i]); timingLoop(1e4); } while (1) {} /* USER CODE END */ }