Hi,
I am trying to use the DMA to write values from the ADC to RAM, but I am having a hard time getting this to work. Does anyone know where some example code is that uses the DMA to write to RAM? Everything I find deals with flash.
Thanks for any help,
Katie
To give you an idea, this is the code that I am using. It is a simple test to see if I can move data from one address to another using the DMA. I was then planning on changing the source address to the ADC once it works. However, it gets stuck on the line: while (!(DMAIRQ& 0x01));
Thanks for your help,
unsigned char Data[8]={ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x99, 0x88, 0x77};unsigned char buf[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};typedef struct { uint8 SRCADDRH; //Byte 0 uint8 SRCADDRL; //Byte 1 uint8 DESTADDRH; //Byte 2 uint8 DESTADDRL; //Byte 3 uint8 LENH:5; //Byte 4 - Bit 4:0 uint8 VLEN:3; //Byte 4 - Bit 7:5 uint8 LENL; //Byte 5 uint8 TRIG:5; //Byte 6 - Bit 4:0 uint8 TMODE:2; //Byte 6 - Bit 6:5 uint8 WORDSIZE:1; //Byte 6 - Bit 7 uint8 PRIORITY:2; //Byte 7 - Bit 1:0 uint8 M8:1; //Byte 7 - Bit 2 uint8 IRQMASK:1; //Byte 7 - Bit 3 uint8 DESTINC:2; //Byte 7 - Bit 5:4 uint8 SRCINC:2; //Byte 7 - Bit 7:6} DMA_DESC;void WriteFlashDMA(uint8 *data, uint16 length, uint16 flashadr){ DMA_DESC dmaConfig0; dmaConfig0.SRCADDRH = ((uint16)data >> 8) & 0x00FF; dmaConfig0.SRCADDRL = (uint16)data & 0x00FF; dmaConfig0.DESTADDRH = (((uint16)&buf) >> 8) & 0x00FF; dmaConfig0.DESTADDRL = ((uint16)&buf) & 0x00FF; dmaConfig0.VLEN = 0; dmaConfig0.LENH = (length>>8) & 0x00FF; dmaConfig0.LENL = length & 0x00FF; dmaConfig0.WORDSIZE = 0; dmaConfig0.TMODE = 0; dmaConfig0.TRIG = 0; dmaConfig0.SRCINC = 1; dmaConfig0.DESTINC = 1; dmaConfig0.IRQMASK = 0; dmaConfig0.M8 = 0; dmaConfig0.PRIORITY = 2; // while (FCTL & 0x80); // FADDRH =(flashadr >> 10) & 0x00FF; // FADDRL = (flashadr >> 2) & 0x00FF; //need to set the DMAREQ.DMAREQx bit to start transfer DMA0CFGH = (((uint16)&dmaConfig0) >> 8) & 0x00FF; DMA0CFGL = ((uint16)&dmaConfig0) & 0x00FF; DMAARM |= 0x01; DMAREQ = 0x01; //change least sig bit for channel 0 DMAIRQ = 0x00; // FCTL |= 0x02; while (!(DMAIRQ& 0x01)); DMAIRQ = 0xFE; // while (FCTL & (0x80));
}
void main(){ uint16 flashAddr = 0x7475; WriteFlashDMA(Data,8,flashAddr);
You can look at the HAL module that uses DMA to move bytes from the UxDBUF to a queue in XDATA (aka RAM):
C:\Texas Instruments\ZStack-CC2530-2.5.0\Components\hal\target\CC2530EB\_hal_uart_dma.c
Hi Dirty Harry,
I was hoping not to add complexity to my code by using zstack, it has a lot of stuff that I don't need. Is it not easy/possible to use the dma to write to ram without using either zstack or timac? Thanks for your quick response,
I was trying to answer your question: "Does anyone know where some example code is that uses the DMA to write to RAM?" by pointing you to a module that uses the DMA to transfer bytes from an SOC peripheral to the XDATA RAM. Although you will want to transfer bytes from the ADC peripheral and the "example code" that I reference transfers from the UART peripheral, it is nonetheless simple, example code of how to setup the DMA channel which you can take or leave. By no means am I recommending you to use the Z-Stack - although, to tell you the truth, I was presuming that you were since you posted in this E2E forum instead of the Proprietary Software forum.