如题。我用stm8s103f3 测试adc。发现adc中断进不去。各位大侠看看我设置的与问题吗?
void adc_init(void)
{
ADC_CR1_ADON = 1; //打开adc
ADC_CSR_CH = 2; //AIN2脚
ADC_CSR_EOCIE = 1; //打开ADC中断
ADC_CR1_SPSEL = 2; //4分频时钟
}
#pragma vector = 0x18
__interrupt void ADC_EOC(void)
{
//add your code
}
单次转换模式。我每执行一次ADC_CR1_ADON = 1; 应该会进入中断一次的才对。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
void main(void)
{
CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV16);
ADC2_Init(ADC2_CONVERSIONMODE_CONTINUOUS, ADC2_CHANNEL_3, ADC2_PRESSEL_FCPU_D2, ADC2_EXTTRIG_TIM, DISABLE, ADC2_ALIGN_RIGHT, ADC2_SCHMITTTRIG_ALL, ENABLE);
ADC2_ITConfig(ENABLE);
enableInterrupts();
ADC2_StartConversion();
/* Infinite loop */
while (1)
{
}
}
INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
uint16_t ADC2_value;
ADC2_value = ADC2_GetConversionValue();
ADC2_ClearITPendingBit();
}
一周热门 更多>