Так мне и не удалось по-нормальному запустить DMA...
Пытался запустить пример к книге The insiders guide to the NXP LPC2300 2400 Based Microcontrollers.
Для запуска под keil пришлось:
- добавить объявление
unsigned int *Buffer1,*Buffer2; - заменить
GPDMA_CH0_LLI = (unsigned int *) item1; на
GPDMA_CH0_LLI = (unsigned int) item1;В результате - все как и раньше - копируется только первый блок из 0x7FD00000 в 0x7FD00500, а уже из 0x7FD00000 в 0x7FD00600 копирования не происходит...
Ну и ес-но виснет на
while ( !GPDMA_RAW_INT_CSTAT );CODE
#include "lpc230x.h"
#define DMA_SRC 0x7FD00000
#define DMA_DST 0x7FD00500
#define DMA_SIZE 0x100
unsigned int i;
unsigned int *Buffer1,*Buffer2;
volatile unsigned int item1[4] = {0x7FD00000,0x7FD00600,0,0x8C4A4000};
int main (void)
{
T0TCR = 0x00000002; //Reset counter and prescaler
Buffer1 = (unsigned int *)DMA_SRC; //Set the start address of the source buffer
Buffer2 = (unsigned int *)DMA_DST; //Set the start address of the destination buffer
for ( i = 0; i < DMA_SIZE/4; i++ ) //Initilise the buffers
{
*Buffer1 = i;
*Buffer2 = 0;
Buffer1++;
Buffer2++;
}
PCONP |= (0x1<<29); // Power up the GPDMA
GPDMA_CONFIG = 0x01; // Enable the GPDMA
while ( !(GPDMA_CONFIG & 0x01) ); // Wait until the GPDMA is operational
GPDMA_INT_CCLR = 0x01; //Clear the interrupt status bits
GPDMA_INT_ERR_CLR = 0x01;
GPDMA_CH0_SRC = DMA_SRC; //Load buffer1 start address into Channel 0
GPDMA_CH0_DEST = DMA_DST; //Load buffer2 start address into Channel0
GPDMA_CH0_CTRL = ((DMA_SIZE/4) & 0x0FFF) //set the transfer size
| (0x04 << 12) // Source burst size
| (0x04 << 15) //destination burst size
| (0x02 << 18) //Source width
| (0x02 << 21) //destination width
| (1 << 26) //Source increment
| (1 << 27) //Destination increment
| (0<<31); //Enable the terminal count interrupt
GPDMA_CH0_LLI = (unsigned int) item1;
T0TCR = 0x00000001; //enable timer
GPDMA_CH0_CFG |= 0x08001; //Start the channel zero transfer
while ( !GPDMA_RAW_INT_CSTAT ); //Wait until the transfer has finished
T0TCR = 0x00000000; //disable timer
T0TCR = 0x00000002; //Reset counter and prescaler
while(1)
{
;
}
return (0);
}
Пробовал массив размещать в "разрешенной" для DMA памяти - по адресу 0x7FD00700 - результат тот-же...
Что нужно сделать, что б заставить копировать несколько блоков? Может у кого-то есть работающий пример?
Сообщение отредактировал i.cf - Sep 2 2009, 19:13