#include "exti.h"
#include "stm32f10x_lib.h"
#include "sys.h"
#include "delay.h"
#include "led.h"
#include "Key.h"
#include "usart.h"
void Exti_Init(){
//PC13输出低电平
RCC->APB2ENR |=1<<4;//enable clock of PORTC
RCC->APB2ENR|=1<<0;
GPIOC->CRH &= 0xff0fffff;
GPIOC->CRH |= 0x00300000;//PC13推挽输出 m默认下拉
GPIOC->ODR &= ~(1<<13);
//PC0中断输入
GPIOC->CRL &= 0xfffffff0;
GPIOC->CRL |= 0x00000008;
GPIOC->ODR |= 1<<0;//上拉
Ex_NVIC_Config(GPIO_C,0,1);//下降沿触发
MY_NVIC_Init(2,2,EXTI0_IRQChannel,2);//抢占2,子优先级2,组2
//将中断线有PA0映射到PC0
//GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource0);
//AFIO->EXTICR[0 >> 0x02] &= ~(0x0F << 0x04);
//AFIO->EXTICR[0 >> 0x02] |= 0x01;
AFIO->EXTICR[0] &= 0xffffff0f;
AFIO->EXTICR[0] |= 0x00000010;
}
//中断处理函数
void EXTI0_IRQHandler(){
u16 i = 0;
u16 key;
LED0 = !LED0;
delay_ms(10);//消抖
if (PCin(0) == 0)
{
printf("please input the number:\t");
Key_Init();
//按键扫描5s
while (1)
{
key = Key_Scan();
if (key <16)
{
printf("%d",key);
}
i++;
if (i ==500 )
{
i = 0;
break;
}
delay_ms(10);
}
}
Exti_Init();
}
#ifndef __EXTI_H
#define __EXIT_H
#include "sys.h"
void Exti_Init(void);
#endif
我是用的pc0 2 3 4 口输出 PC5 11 12 13输入,可是不知道为什么就是加上我的中断(程序如上)后显示就是白屏
|