正在学习32,然后学到ADC时,因为开发板的ADC1是测电位器电压,接在了GPIOA_Pin_1口,先不提ADC配置,一旦我在GPIO口中配置GPIOA_Mode = GPIO_Mode_AIN时,即配置A1脚为模拟输入,则我原来写的中断函数,无论是串口、定时还是外部中断全都进不去,只能在主循环里面转。如果删掉这句或者A1口不为模拟输入的话,所有中断都正常,求大神解答,,,被困了好久了,一直找不到原因,问了别人也说没遇到过。
[mw_shl_code=c,true]
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //?¨??GPIO???????á????
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD, ENABLE); //???í*****?±??
GPIO_SetBits(GPIOB,GPIO_Pin_0 | GPIO_Pin_1); //LED??????????
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_5; //°??ü????????
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* ?®??????*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;//USART TX?è???????ì????????
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//???????????????ò??????
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//USART RX?è????????????
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;//AD????????
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;//????????
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOA, &GPIO_InitStructure);
}[/mw_shl_code]
[mw_shl_code=c,true]int main(void)
{
// u16 AD;
// u8 AD_H, AD_L;
RCC_Configuration();
GPIO_Configuration();
EXTI_Configuration();
USART1_Configuration();
NVIC_Configuration();
TIM2_Configuration();
// ADC_Configuration();
delay_init(72);
while(1)
{
if(GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_0)==Bit_SET)
GPIO_ResetBits(GPIOB,GPIO_Pin_0);
else
GPIO_SetBits(GPIOB,GPIO_Pin_0);
if(GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_1)==Bit_SET)
GPIO_ResetBits(GPIOB,GPIO_Pin_1);
else
GPIO_SetBits(GPIOB,GPIO_Pin_1);
delay_ms(500);[/mw_shl_code]
|