Hi all,
I'm new to LPC and need some help. I wanna set up a Timer triggered DMA transfer to transfer data from pin to a defined adress in the SRAM1. Every time the MR0 matches the DMA transfer should start. I work with the LPC4088 Quickstart Board. I set the Board up to run at 120MHz. My Peripherals also run at 120MHz. I studied the UM and wrote some code but when I compile nothing happens. The timer works fine and I see a 10MHz output on the defined pin.
I attached my simple code I wrote extra for this.
Hope anyone of you can help me.
Best Tim
#include "LPC407x_8x_177x_8x.h"
#define PERIPHSRAM1 0x20004000
char adcData[11] = {1,1,1,1,1,1,1,1,1,1,1};
volatile uint32_t DMATCCOUNT = 0;
volatile uint32_t DMAERRCOUNT = 0;
void DMA_IRQHandler(){
uint32_t temp;
DMATCCOUNT++;
temp = LPC_GPDMA->IntTCStat;
if(temp){
DMATCCOUNT++;
LPC_GPDMA->IntTCClear |= temp;
}
temp = LPC_GPDMA->IntErrStat;
if(temp){
DMAERRCOUNT++;
LPC_GPDMA->IntErrClr |= temp;
}
return;
}
int main(){
uint8_t size = sizeof(adcData);
LPC_SC->PCONP |= (1 << 22);
LPC_TIM2->CTCR = (0 << 0);
LPC_TIM2->PR = 0;
LPC_TIM2->TCR = (1 << 1);
LPC_TIM2->TC = 0;
LPC_TIM2->MR0 = 5;
LPC_TIM2->MCR = (1 << 1)
|(1 << 0);
LPC_TIM2->EMR = 0x31;
LPC_TIM2->TCR = (1 << 1);
LPC_SC->PCONP |= (1 << 29);
LPC_GPDMACH0->CConfig = 0;
LPC_GPDMA->Config |= (1 << 0);
LPC_SC->DMAREQSEL = 0x010;
LPC_GPDMA->IntErrClr |= 0x0FF;
LPC_GPDMA->IntTCClear |= 0x0FF;
LPC_GPDMACH0->CDestAddr = PERIPHSRAM1;
LPC_GPDMACH0->CSrcAddr = (uint32_t) &adcData;
LPC_GPDMACH0->CControl = size
|(0x03 << 12)
|(0x03 << 15)
|(0x01 << 18)
|(0x01 << 21)
|(0x01 << 26)
|(0x01 << 27)
|(0x01 << 31);
LPC_GPDMACH0->CControl |= (4 << 1)
|(0 << 11);
NVIC_SetVector(DMA_IRQn, (uint32_t) DMA_IRQHandler);
NVIC_EnableIRQ(DMA_IRQn);
LPC_GPDMACH0->CConfig |= 1;
LPC_TIM2->IR |= 0x0FF;
LPC_TIM2->TCR = 0x01;
while(!DMATCCOUNT);
while(1){
}
}