我准备利用按键产生中断来控制led灯的变化,按键接在eint4567管脚上,可是我的程序运行后发现无法进入中断,希望各位大虾能够指点,不胜感激!!
init.s代码:
INTMSK EQU 0x01e0000c
WTCON EQU 0x01d30000
IMPORT HandlerEINT4567
AREA Init,CODE,READONLY
ENTRY
b ResetHandler ; 0x00 Reset
b . ; 0x04 Undef
b . ; 0x08 SWI interrupt handler
b . ; 0x0c handlerPAbort
b . ; 0x10 handlerDAbort
b . ; 0x14 handlerReserved
b . ; 0x18 IRQ
b . ; 0x1c FIQ
b . ; 0x20
b .
b .
b .
b .
ldr pc,=HandlerEINT4567
IMPORT Main
ResetHandler
; Disable all interrupt
ldr r0,=INTMSK
ldr r1,=0x07ffffff
str r1,[r0]
; Initialize Stacks
ldr r13, =SVCStack
; Disable watch dog
ldr r0, =WTCON
ldr r1, =0x0
str r1,[r0]
; Set the CPU mode if necessary
; Branch to the C program main process
BL Main
; *******************************************************
; Stack data area define
; *******************************************************
ALIGN
AREA RamData, DATA, READWRITE
; Where the stacks grows
MAP 0x0C000200
SVCStack # 256
IRQStack # 256
END
main.c代码:
#include "f:\arminclude\44b.h"
#include "f:\arminclude\option.h"
volatile char which_int=0;
__inline void enable_IRQ(void)
{
int tmp;
__asm
{
MRS tmp, CPSR
BIC tmp, tmp, #0x80
MSR CPSR_c, tmp
}
}
__inline void disable_IRQ(void)
{
int tmp;
__asm
{
MRS tmp, CPSR
ORR tmp, tmp, #0x80
MSR CPSR_c, tmp
}
}
void led_display(int m)
{
switch (m)
{
case 3:
rPDATF=rPDATF^0x20;
break;
case 4:
rPDATF=rPDATF^0x40;
break;
case 5:
rPDATF=rPDATF^0x80;
break;
case 6:
rPDATF=rPDATF^0x100;
break;
default:
break;
}
}
void __irq HandlerEINT4567(void)
{
which_int=rEXTINTPND; //获取中断源为中断4567中的哪一个
rEXTINTPND=0xf; //clear EXTINTPND reg.
rI_ISPC=BIT_EINT4567; //clear pending_bit
switch(which_int)//根据中断源,点亮led
{
case 1:
led_display(3);
which_int=0;
break;
case 2:
led_display(4);
which_int=0;
break;
case 4:
led_display(5);
which_int=0;
break;
case 8:
led_display(6);
which_int=0;
break;
default :
break;
}
}
void port_init(void)
{
rPCONF=0x09240a;
rPUPF=0x1f;
rPDATF=0x0;
}
void isr_Init(void)
{
rINTCON=0x5; // IRQ中断使能
rINTMOD=0x0; // All=IRQ mode
rPCONG=0xffff; //EINT7~0
rPUPG=0x0; //pull up enable
rEXTINT=0x0; // 使能低电平触发
rINTMSK=~(BIT_GLOBAL|BIT_EINT4567); file://start INT,去除外EINT4567的屏}
int Main(void)
{
// rSYSCFG=0x0e; //使用8K字节的指令缓存
port_init(); //IO端口功能、方向设定
isr_Init(); //中断初始化
enable_IRQ ();
while(1);
}
[em01][em01]
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |