您的位置 首页 动态

s3c6410 的外部中止完成

6410各个中断寄存器的关系图EINT0CON0ExternalInterrupt0(Group0)ConfigurationRegister0设置外部中断的触发方式(高电平…

6410各个中止寄存器的联系 图

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(V%&&&&&%0IRQSTATUS &(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

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/dongtai/274544.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部