adc中断调通,用软件触发能够实现。tim2中断调通,但怎样将adc转接到tim2的cc2上,进行驱动就实现不了了。
ADC初试代码如下:
ADC1_CR2 |= CR2_ADON;
ADC1_CR2 |= CR2_RSTCAL;
for(int i=0; i<200; i++)
{
}
ADC1_CR2 |= CR2_CAL;
for(int i=0; i<200; i++)
{
}
//3.adc模块自身配置,仅使用ADC1
ADC1_SQR3 = 0;
//ADC1_CR2 = CR2_ADON;
aaaa = 0;
NVIC_IRQ_Enable(E_IRQ_ADC1_2);
ADC1_CR1 |= CR1_EOCIE;
ADC1_CR2 |= (BIT18+BIT17);
ADC1_CR2 |= CR2_EXTTRIG;
TIM2初始代码如下:
//向上计数,不分频
TIM2_ARR = 1000;
TIM2_EGR = EGR_UG; //立即更新
TIM2_CCR2 = 500;
TIM2_PSC = 8000;
TIM2_CCER |= CCER_CC2E;
TIM2_CCMR1 |= 1<<12;
//NVIC_IRQ_Enable(E_IRQ_TIM2);
//TIM2_DIER |= DIER_CC1IE;
TIM2_CR1 |= CR1_CEN; |