Hi,
I need to implement a ADC double buffering using DMA. I've setup the ADC with FIFO size of 32 8BIT samples and the ADC RAM of 64 sample. The DMA would be triggered every FIFO sample so will transfer the first half of the ADC RAM while the ADC write the second half and so on. The DMA destination buffer is 512Bytes.
My DMA control packet is set as follow:
g_dmaCTRLPKT.SADD = (uint32)adcRAM1; /* source address */
g_dmaCTRLPKT.DADD = (uint32)&Buffer; /* destination address */
g_dmaCTRLPKT.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT.FRCNT = 16; /* frame count */
g_dmaCTRLPKT.ELCNT = 32; /* element count */
g_dmaCTRLPKT.ELDOFFSET = 0; /* element destination offset - is required? */
g_dmaCTRLPKT.ELSOFFSET = 0; /* element source offset - is required? */
g_dmaCTRLPKT.FRDOFFSET = 0; /* frame detination offset - is required? */
g_dmaCTRLPKT.FRSOFFSET = 0; /* frame source offset - is required? */
g_dmaCTRLPKT.PORTASGN = 4; /* port b */
g_dmaCTRLPKT.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT.TTYPE = FRAME_TRANSFER ; /* transfer type */
g_dmaCTRLPKT.ADDMODERD = ADDR_FIXED; /* address mode read */
g_dmaCTRLPKT.ADDMODEWR = ADDR_INC1; /* address mode write */
g_dmaCTRLPKT.AUTOINIT = AUTOINIT_ON; /* autoinit (loop) */
dmaSetCtrlPacket(DMA_CH0,g_dmaCTRLPKT);
dmaSetChEnable(DMA_CH0, DMA_HW);
but I'm not sure it is right. In particular ADDMODERD = ADDR_FIXED will cause the DMA read from a fixed address insted of alternating the two half of the ADC RAM. AFAIK the frame and element couts are referred to the destination buffer. How can I setup this behaviour?
thank you,
Matteo