EINT0CON0 External Interrupt 0(Group0) Configuration Register 0
设置 外部中断的触发方式(高电平等)
EINT0PEND External Interrupt 0(Group0) Pending Register 屏蔽前的中断(谁中断,相应位置1)
EINT0MASK External Interrupt 0(Group0) Mask Register 屏蔽(屏蔽谁,相应位置1)
以上两个是管脚级别(GPIO)的pending和mask寄存器;
下边是中断控制器的pending和mask寄存器
VIC0INTENABLE Interrupt Enable Register (VIC0) //相当于mask寄存器
VIC0IRQSTATUS IRQ Status Register (VIC0) 相当与pending寄存器
程序代码
main.c
//led
#define GPKCON (*(volatile unsigned int *)0x7f008800)
#define GPKDAT (*(volatile unsigned int *)0x7f008808)
//button
#define GPNCON (*(volatile unsigned int *)0x7F008830)
#define GPNDAT (*(volatile unsigned int *)0x7F008834)
//beep
#define GPFCON (*(volatile unsigned int *)0x7F0080A0)
#define GPFDAT (*(volatile unsigned int *)0x7F0080A4)
//
#define EINT0CON0 (*(volatile unsigned int *)0x7F008900)
#define EINT0MASK (*(volatile unsigned int *)0x7F008920)
#define EINT0PEND (*(volatile unsigned int *)0x7F008924)
//////interrupt contruller
#define VIC0IRQSTATUS (*(volatile unsigned int *)0x71200000)
#define VIC0INTENABLE (*(volatile unsigned int *)0x71200010)
#define VIC0RAWINTR (*(volatile unsigned int *)0x71200008)
int led_init(void)
{
//GPK4//
GPKCON |= 1<<16;
GPKCON &= ~(1<<17 | 1<<18 | 1<<19);
//GPK5//
GPKCON |= 1<<20;
GPKCON &= ~(1<<21 | 1<<22 | 1<<23);
//GPK6//
GPKCON |= 1<<24;
GPKCON &= ~(1<<25 | 1<<26 | 1<<27 );
//GPK7//
GPKCON |= 1<<28;
GPKCON &= ~(1<<29 | 1<<30 | (unsigned)1<<31);
return 0;
}
void led_value(int value)
{
GPKDAT = ~value << 4;
}
void led_on(void)
{
GPKDAT =0;
}
void led_off(void)
{
GPKDAT = 0xf0;
}
void delay(void)
{
int i = 0;
for(i = 0; i <500000; i++);
}
void led_blink(void)
{
led_on();
delay();
led_off();
delay();
}
void beep_init(void)
{
GPFCON |= 1<<28;
GPFCON &= ~(1<<29);
}
void beep_on(void)
{
GPFDAT |= 1<<14;
}
void beep_off(void)
{
GPFDAT &= ~(1<<14);
}
void beep(void)
{
beep_on();
delay();
beep_off();
delay();
}
void do_irq()
{
//at start, clear pending bit
EINT0PEND = 1<<0;
beep();
/*
void (*pf)(void);
pf = vicoaddress;
(*pf)();
*/
}
void irq_handler(void);
void test(void)
{
GPFDAT |= 1<<14;
}
int mymain(void)
{
int *p;
int counter = 0;
led_init();
beep_init();
//beep();
//GPFDAT |= 1<<14;
//GPNCON &= ~(1<<0 | 1<<1);
//111111GPN0[1:0] interrupt
GPNCON |= 1<<1;
GPNCON &= ~(1<<0);
//2222 EINT0CON1[2:0]
EINT0CON0 &= ~(1<<2);
EINT0CON0 |= 1<<1;
//33333 EINT0MASK[0]
EINT0MASK &= ~(1<<0);
//EINT0MASK |= 1<<0;
//444444 VIC0INTENABLE
VIC0INTENABLE |= 1<<0;
//VIC0INTENABLE &= ~(1<<0);
//555555
//VIC0RAWINTR &= ~(1<<0);
// arm core I_BIT :enable IRQ
__asm
{
mov r0, #0x53
msr CPSR_cxsf, r0
}
p = (int *)0x18;
*p = 0xe59ff000;
p = (int *)0x20;
*p = (int)irq_handler;
/*
VIC0VECADDR0 = beep1;
VIC0VECADDR0 = beep2;
*/
while(1)
{
if(VIC0IRQSTATUS &(1<<0))
{
beep();
}
led_value(counter & 0x0f);
counter++;
delay();
//if(GPNDAT & (1<<0))
// led_on();
//else
// led_off();
}
return 0;
}
start.s文件
AREA int, CODE, READONLY
import mymain
ENTRY
;sp_irq mode
mov r0, #0xd2
msr cpsr_cxsf,r0
ldr sp, =0x50200000
;sp_svc mode
mov r0, #0xd3
msr cpsr_cxsf, r0
ldr sp, =0x50100000
b mymain
import do_irq
export irq_handler
irq_handler
;push rets to stack
stmfd sp!,{r0-r12,lr} //r0-r12 和lr压栈保护;
;handler
bl do_irq
;pop stack to regs
ldmfd sp!, {r0-r12,lr}
subs pc, lr,#4
END
上一篇:s3c6410 定时器中断的实现
下一篇:s3c6410 s3c2440串口发送接收数据的实现(轮询)及相关寄存器
推荐阅读最新更新时间:2024-03-16 15:04
设计资源 培训 开发板 精华推荐
- 最后一周报名,STM32中国峰会暨粉丝狂欢节,5月12-13日深圳
- 有奖直播|TI Matter 解决方案助力智能家居创新
- 【玩转+显摆】C2000 Launchpad!!!
- 有奖直播:安世半导体先进 SiC MOSFET 助力提升 EV-Charger 和 OBC 应用能效
- 看视频抽好礼:Type-C承载的高速串行标准,功能多样,挑战也不小
- 希望一月 爱上EEWORLD——论坛推广月
- 将想法变成现实,Maxim MAX32630FTHR创意设计大赛,重磅开启!
- TI“无线”风光可穿戴现场培训直播,诚邀参与,预注册赢好礼
- 初识易电源——聊聊你眼中的易电源!
- EDI CON 2020 门票免费领