请教一个DMA的问题:我使用外部中断触发置标志位,while里根据标志位开启ADC+DMA,并且关灯,而DMA中断里点灯。
经过示波器查看,发现点灯比中断时延13us,而我设置的DMA采集缓存是150us的数据点数。难道13us,DMA就采样完成了了,进入DMA中断里?这和DMA产生中断的理念不符啊。。。——凌乱了。。。求解惑此现象。
外部中断每秒一次。
补充说明:我的DMA使用是正常的,但产品对延时要求高,需要测出DMA采样的延时,包括ADC上电稳定的时间差和漂移时间。这方面的测试样例网上很少。
void DMA2_Stream0_IRQHandler(void)
{
if(DMA_GetFlagStatus(DMA2_Stream0, DMA_FLAG_TCIF0)==SET)
{
GPIOD->BSRRL = GPIO_Pin_14;
//清除全部中断标志。如果关闭ADC和DMA,还是否需要清标志位
DMA_ClearFlag(DMA2_Stream0, DMA_FLAG_TCIF0);
DMA_Cmd(DMA2_Stream0, DISABLE);
// Disable ADC3 ,ADC断电,等待中断触发再上电。
ADC_Cmd(ADC3, DISABLE);
}
}
while (1)
{
//GPIOD->BSRRL = GPIO_Pin_14;
GPIOD->BSRRH = GPIO_Pin_14;
//GPIOD->BSRRL = GPIO_Pin_14;
GPIOD->BSRRH = GPIO_Pin_14;
/******Pa4外部中断************/
if(EX
ti_Pa5Flag)
{
ADC_Cmd(ADC3, ENABLE);
ADC3_CH11_DMA_Config();
ADC_SoftwareStartConv(ADC3);
EXTI_Pa5Flag = 0;
}
}
//DMA的配置
DMA_InitStructure.DMA_Channel = DMA_Channel_2;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADC3ConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = ADC3_RAM_SIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
一周热门 更多>