I am in the use of LPC4370 microcontroller HSADC+DMA, if each time in the DMA before do some global variable bit operations, each DMA into the interrupt time will be longer, do not know what is the reason, do not have brothers know?
My code:
void DMA_IRQHandler(void)
{
if(LPC_GPDMA->INTSTAT & (1UL << 7))
{
LPC_GPDMA->INTTCCLEAR |= (1UL <<7);
LPC_GPIO_PORT->B[0][13] = false;
ucColletStop = 1;
}
}
int main(void)
{
SystemCoreClockUpdate();
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 13);
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 13, false);
HsadcInit();
DmaInit();
for(uint32_t i = 50000000; i > 0; i--){__asm("nop");}//1s
LPC_GPIO_PORT->B[0][13] = true;
Chip_HSADC_SWTrigger(LPC_ADCHS);
while(1)
{
if(ucColletStop == 1)
{
ucColletStop = 0;
for(uint32_t i = 1000000; i > 0; i--){__asm("nop");}//20ms
Chip_HSADC_SetActiveDescriptor(LPC_ADCHS, 1, 0);//Stop HSADC
Chip_HSADC_SWTrigger(LPC_ADCHS);
for(uint32_t i = 1000000; i > 0; i--){__asm("nop");}//20ms
for(uint16_t i = 0; i < 1024; i++)
{
ulConvertedData[2*i] = dma_buffer[i]&0xFFF;
ulConvertedData[2*i+1] = (dma_buffer[i]>>16)&0xFFF;
}
for(uint32_t i = 1000000; i > 0; i--){__asm("nop");}//20ms
Chip_HSADC_SetActiveDescriptor(LPC_ADCHS, 0, 1);//Start HSADC
CollectStart();//Start DMA
Chip_HSADC_SWTrigger(LPC_ADCHS);
LPC_GPIO_PORT->B[0][13] = true;
}
}
}