#define ADC3_DR_Address ((u32)0x40013C4C) ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//ADC1和ADC2工作在独立模式 ADC_InitStructure.ADC_ScanConvMode = ENABLE; //使能扫描 ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;//ADC转换工作在单次模式 ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T2_CC2;//定时器2的捕获比较2为转换外部触发 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//转换数据右对齐 ADC_InitStructure.ADC_NbrOfChannel = 10;//转换通道为通道1 ADC_Init(ADC3, &ADC_InitStructure); //初始化ADC ADC_RegularChannelConfig(ADC3, ADC_Channel_1, 1, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_12, 2, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_8, 3, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 4, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_11, 5, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_10, 6, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_13, 7, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_5, 8, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_6, 9, ADC_SampleTime_28Cycles5 ); ADC_RegularChannelConfig(ADC3, ADC_Channel_4, 10, ADC_SampleTime_28Cycles5 ); ADC_DMACmd(ADC3, ENABLE);//使能ADC3模块DMA ADC_Cmd(ADC3, ENABLE);//使能ADC1 ADC_ResetCalibration(ADC3); //重置ADC1校准寄存器 while(ADC_GetResetCalibrationStatus(ADC3));//等待ADC1校准重置完成 ADC_StartCalibration(ADC3);//开始ADC1校准 while(ADC_GetCalibrationStatus(ADC3));//等待ADC1校准完成 ADC_ExternalTrigConvCmd(ADC3, ENABLE); ////设置外部事件为TIM2_CC2 DMA_DeInit(DMA2_Channel5);//复位DMA通道5 DMA_InitStructure.DMA_PeripheralBaseAddr = ADC3_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC3ConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 10; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//当前存储器地址不变 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//定义外设数据宽度16位 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; //定义存储器数据宽度16位 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA通道操作模式位环形缓冲模式 DMA_InitStructure.DMA_Priority = DMA_Priority_High;//DMA通道优先级高 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;//禁止DMA通道存储器到存储器传输 DMA_Init(DMA2_Channel5, &DMA_InitStructure); DMA_Cmd(DMA2_Channel5, ENABLE); //使能DMA通道5 DMA_ITConfig(DMA2_Channel5, DMA_IT_TC, ENABLE); void DMA2_Channel4_5_IRQHandler(void) { DMA_ClearFlag(DMA2_FLAG_GL5 ); } void Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); NVIC_InitStructure.NVIC_IRQChannel = DMA2_Channel4_5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } |
RE:stm32f103zet6使用adc3通过dma2_5,为什么进不了dma2_5中断。求高人指点
ad3 启动转换条件中没有ADC_ExternalTrigConv_T2_CC2
改为ADC_ExternalTrigConv_T2_CC3就行了
RE:stm32f103zet6使用adc3通过dma2_5,为什么进不了dma2_5中断。求高人指点