用定时器3的TRGO触发ADC转换,利用ADC中断计算,配置如下,但是ADC中断进入不了。不知道什么原因,哪位给指导一下呗!谢谢。 void Init_TIMER3(void) { TIM_TimeBaseInitTypeDef TIM_BaseInitStructure; //定义一个定时器结构体变量 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //使能定时器3,重要!! TIM_DeInit( TIM3); //将IM3定时器初始化位复位值 TIM_BaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_BaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_BaseInitStructure.TIM_Period = 1; TIM_BaseInitStructure.TIM_Prescaler = 7199; TIM_TimeBaseInit(TIM3,&TIM_BaseInitStructure); TIM_SelectOutputTrigger(TIM3,TIM_TRGOSource_Update); //选择TRGO触发源为计时器更新时间 TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); TIM_Cmd(TIM3,ENABLE); } void NVIC_Configuration(void) { NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn; // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //响应优先级0 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //允许中断 NVIC_Init(&NVIC_InitStructure); //根据指定参数初始化中断寄存器 } void ADC1_Configuration(void) { /* ADC1 configuration ------------------------------------------------------*/ ADC_InitTypeDef ADC_InitStructure; ADC_DeInit(ADC1); ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_NbrOfChannel = M; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO; ADC_InitStructure.ADC_DataAlign =ADC_DataAlign_Right; ADC_Init(ADC1,&ADC_InitStructure); ADC_ExternalTrigConvCmd(ADC1,ENABLE); ADC_ITConfig(ADC1,ADC_IT_EOC,ENABLE); } void ADC1_2_IRQnHandler(void) { while (ADC_GetITStatus(ADC1,ADC_IT_EOC)==RESET) { ADC_ClearITPendingBit(ADC1,ADC_IT_EOC); // ADC_GetConversionValue(ADC1); if(Status) { TEST1=1; TEST2=1; Status=0; } else { TEST1=0; TEST2=0; Status=1; } } } |
RE:stm32 adc中断问题
回复:stm32 adc中断问题
|RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC
|RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE
|RCC_APB2Periph_ADC1 | RCC_APB2Periph_AFIO
|RCC_APB2Periph_SPI1 | RCC_APB2Periph_USART1, ENABLE );
ADC能工作,但是不能进入中断呀。哪不对呢?