you

外部中断(2)



#include "key.h"
void hander_irq();
void led_on();
void led_off();
void wat_on();
void wat_off();
int (*printf)(char *,...) = (void *)0x57e11d4c;
int flag =1;
int flag_two = 1;
int main()
{
*(volatile unsigned long *)0x56000000 = hander_irq;
//cpsr
__asm__ __volatile__(


"mrs r0,cpsr\n"
"bic r0,r0,#0x80\n"
"msr cpsr,r0\n"
:
:
:"r0","memory"
);
//enable
VIC0INTENABLE |=((1<<0)|(1<<26));
//select
VIC0INTSELECT &= ~((1<<0)|(1<<26)); 
//ex_interrupt
//key 配成中断
GPNCON = 2; 
//ext_interrupt上升沿
EINT0CON0 |= (1<<1);
EINT0MASK &= ~(1<<0);
//int_interrupt
//watdog
WTCON = (1<<2)|(0<<3)|(1<<5)|(255<<8);
       // WTCNT = 0x8000;
        WTDAT = 0x2000;

         //led
        GPMCON = (1<<0)|(1<<4)|(1<<8)|(1<<12);
GPMDAT = 0xf;


}
void hander_irq()
{

if(VICxRAWINTR & (1<<0))
{
//clear ext_interrupt_key
EINT0PEND = 1;
printf("this is key\n");
if(flag)
{
wat_on();
}
else{
wat_off();
led_off();
}
flag ^= 1;

if(VICxRAWINTR & (1<<26))
{
//clear int_interruptu_watdong_count
WTCLRINT = 0;
printf("this is watdong\n");
if(flag_two)
{
led_on();
}
else{
led_off();
}
flag_two ^= 1;
}
}


void led_on(){
GPMDAT = 0;
}
void led_off(){
GPMDAT = 0xf;
}
void wat_on(){
  WTCON &= ~(1<<5);

}
void wat_off(){
WTCON |= (1<<5);
}



阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/youhaibo1990/article/details/17153861
文章标签: key
个人分类: [ bootloader-6410X ]
想对作者说点什么? 我来说一句

dsp2812外部中断控制实验程序

2011年01月02日 234KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭