Hi,
I have written this simple code, the Memory to memory DMA would work fine, but when I try to use a timer match to trigeer DMA transfers it would fail with this flag in DMA callback
GPDMA_EVENT_ERROR
Here is my sample code, Do you have any Idea what I'm missing?
void mySPI_callback(uint32_t event)
{
switch (event)
{
case GPDMA_EVENT_TERMINAL_COUNT_REQUEST:
/* Success: Wakeup Thread */
__breakpoint(0); /* Error: Call debugger or replace with custom error handling */
break;
case GPDMA_EVENT_ERROR:
/* Occurs in slave mode when data is requested/sent by master
but send/receive/transfer operation has not been started
and indicates that data is lost. Occurs also in master mode
when driver cannot transfer data fast enough. */
__breakpoint(0); /* Error: Call debugger or replace with custom error handling */
break;
}
}
int main(void)
{
GPDMA_Initialize();
uint16_t TXDummi[8]={0x1234,2,3,4,5,6};
uint16_t RXDummi[8];
//reset on match 0
LPC_TIMER3->MCR=0x00000002;
//Toggle on match 0(initial states are hi)
LPC_TIMER3->EMR=0x00000031;
//Match about 500ms since CPU clock is 180MHz
LPC_TIMER3->MR0=90000000;
//Clear timer interrupts
LPC_TIMER3->IR=0xFF;
//enable timer
LPC_TIMER3->TCR=0x00000001;
//Select TImer3 MR0 as DMA Request
GPDMA_PeripheralSelect (7, 0);
//Configure Channel 1 of DMA
GPDMA_ChannelConfigure (0,
(uint32_t)LPC_TIMER3->TC,
(uint32_t)RXDummi,
256,//800 bytes
GPDMA_CH_CONTROL_SBSIZE(GPDMA_BSIZE_8) |
GPDMA_CH_CONTROL_DBSIZE(GPDMA_BSIZE_1) |
GPDMA_CH_CONTROL_SWIDTH(GPDMA_WIDTH_HALFWORD) |
GPDMA_CH_CONTROL_DWIDTH(GPDMA_WIDTH_HALFWORD) |
GPDMA_CH_CONTROL_S |
GPDMA_CH_CONTROL_D |
//GPDMA_CH_CONTROL_DI |
GPDMA_CH_CONTROL_I,
GPDMA_CH_CONFIG_SRC_PERI(7) |
GPDMA_CH_CONFIG_FLOWCNTRL(GPDMA_TRANSFER_P2M_CTRL_PERI) |
GPDMA_CH_CONFIG_IE |
GPDMA_CH_CONFIG_ITC |
GPDMA_CH_CONFIG_E,
mySPI_callback);
while(1)
{
}
}