ADC_DMA
功能实现:ADC DMA方式循环采样。
采集周期:(256-192)*16*Tsys = (256-192)*16/62.4M = 16.5us
进中断周期:16.5us*采集数据 = 16.5us
int main()
{
uint8_t i;
signed short RoughCalib_Value = 0; // ADC粗调偏差值
uint32_t temp = 0;
uint8_t adcchidx = 0;
HSECFG_Capacitance(HSECap_18p);
SetSysClock(CLK_SOURCE_HSE_PLL_62_4MHz);
/* 配置串口调试 */
DebugInit();
PRINT("Start @ChipID=%02X\n", R8_CHIP_ID);
GPIOA_ResetBits(GPIO_Pin_1);
GPIOA_ModeCfg(GPIO_Pin_1, GPIO_ModeOut_PP_5mA);
/* DMA单通道采样:选择adc通道0做采样,对应 PA4引脚 */
PRINT("\n3.Single channel DMA sampling...\n");
GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeIN_Floating);
ADC_ExtSingleChSampInit(SampleFreq_8_or_4, ADC_PGA_0);
ADC_ChannelCfg(0);
ADC_ExcutSingleConver();//时间足够时建议再次转换并丢弃首次ADC数据
ADC_AutoConverCycle(192); // 采样周期为 (256-192)*16个系统时钟
ADC_DMACfg(ENABLE, (uint32_t)&adcBuff[0], (uint32_t)&adcBuff[1], ADC_Mode_LOOP);
PFIC_EnableIRQ(ADC_IRQn);
ADC_StartAutoDMA();
while(1);
}
__INTERRUPT
__HIGH_CODE
void ADC_IRQHandler(void) //adc中断服务程序
{
GPIOA_InverseBits(GPIO_Pin_1);
if(ADC_GetDMAStatus())
{
R32_ADC_DMA_BEG = ((uint32_t)adcBuff) & 0x1ffff;
ADC_ClearDMAFlag();
}
}