求助!!!!怎么配置中断啊,为什么这个外部中断就是进不了中断服务程序

2019-03-23 19:31发布

#include "stm32f10x_lib.h"


void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void EXIT_Configuration(void);

int main(void)
{
RCC_Configuration();

NVIC_Configuration();

GPIO_Configuration();

EXIT_Configuration();

GPIO_WriteBit(GPIOB, GPIO_Pin_8,(BitAction)0x01);
GPIO_WriteBit(GPIOB, GPIO_Pin_9,(BitAction)0x00);

}

void EXIT_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;

EXTI_ClearITPendingBit(EXTI_Line9);



/* Configure Key Button EXTI Line to generate an interrupt on falling edge */
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_Line = EXTI_Line9;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);
}




void RCC_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
}

void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
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_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
}

void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;

/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

NVIC_SetVectorTable (NVIC_VectTab_FLASH ,0x0);

/* Enable the EXTI9_5 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

void EXTI9_5_IRQHandler(void)
{
u16 i,j;
if(EXTI_GetITStatus(EXTI_Line9) == 1 ) //判断中断发生来源
{
EXTI_ClearITPendingBit(EXTI_Line9); //清除中断标志
for(i=0;i<2550;i++)
{ for (j=0;j<255;j++);} //发送字符"a"
GPIO_WriteBit(GPIOB, GPIO_Pin_8,(BitAction)0x00);

for(i=0;i<2550;i++)
{ for (j=0;j<255;j++);}
GPIO_WriteBit(GPIOB, GPIO_Pin_8,(BitAction)0x01);
}
} 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
cainana123456
1楼-- · 2019-03-24 00:46
 精彩回答 2  元偷偷看……
亮0000仔
2楼-- · 2019-03-24 03:47
你的问题和我一样。。你怎么解决的??

一周热门 更多>