程序中目的:通过设置PA10作为中断源,当PA10上升沿时进入中断;
遇到的问题: 1.运行初始化中断配置程序后,我试图用程序直接将PA10置1来进入中断,然而此时不能将PA10置1 (但是放在初始化中断之前可以将PA10置1),故而不能进入中断?
2.这种PA10作为中断源,然后使用软件置1。这种方法是否能实现,或者存在问题呢?
程序代码:(PA10的初始化前面已定义)
static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = KEY1_INT_EXTI_IRQ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI_Key_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
RCC_AHB1PeriphClockCmd(KEY1_INT_GPIO_CLK,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
NVIC_Configuration();
GPIO_InitStructure.GPIO_Pin = KEY1_INT_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(KEY1_INT_GPIO_PORT, &GPIO_InitStructure);
SYSCFG_EXTILineConfig(KEY1_INT_EXTI_PORTSOURCE,KEY1_INT_EXTI_PINSOURCE);
EXTI_InitStructure.EXTI_Line = KEY1_INT_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void xuantong(int w0, int w1,int w2,int w3,int w4, int z1)
{
GPIO_SetBits(KEY1_INT_GPIO_PORT,KEY1_INT_GPIO_PIN); //CSÐźÅÖÃ룬ADоƬ׼±¸¹¤×÷
EXTI_Key_Config();
if(w0==1)
{
EN_enable( 11,w1 );
EN_enable( 12,w2 );
EN_enable( 21,w3 );
EN_enable( 22,w4 );
for(i1=0;i1<15;i1++)
{
road_enable(21,z2);
road_enable(22,z2);
Key_port_HIGH(); //此处是将PA10置1的程序,试图将PA10软件置1后,进入中断服务函数
}
}
}
|