免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 908 | 回复: 0
打印 上一主题 下一主题

外部中断代码分析 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-03 16:17 |只看该作者 |倒序浏览

               
前几天看了下44b0的中断介绍,今天拿开发板带的测试用例来对着看中断这部分的代码,
void Eint567_Test( void )
{
 printf( "\nInterrupt Test!\n" );
 
    printf("\n\n注意由于本项测试使用了中断,所以必须将本项目的目标代码烧写入Flash的0地址\n");
    printf("这样Flash中才有中断向量,不过只需要烧入一次就行了,以后JTAG调试或网口下载运行本程序就没有问题了\n");
    printf("可以使用netload或者是comload下载本目标代码到SDRAM,然后用Prog 0烧写代码到Flash(不覆盖0地址跳转指令)\n\n");
    pISR_EINT4567 = (unsigned)Key_Interrupt ;
 
       pISR_EINT1 = (unsigned)EINT1_Interrupt ;
 rINTCON = 0x5 ;                //无向量中断模式
 rINTMOD = 0x0 ;                //All=IRQ mode
    rPCONG = rPCONG | ( 0x3f<<10 );                //EINT7~5
    rPUPG = rPUPG & (~(7<<5)) ;                //pull up resister is enable
 rEXTINT = rEXTINT & (~(0xfff<<20)) ;                //EINT567低电平触发中断
 
    pISR_EINT4567 = (unsigned)Key_Interrupt ;
//    rINTMSK = ~( BIT_GLOBAL | BIT_EINT4567 ) ;                //start INT
    rINTMSK = ~( BIT_GLOBAL | BIT_EINT4567 | BIT_EINT1 ) ;                //start INT
 
        
      
 printf( "\nPlease press the button key2,key3,key4!   Press ESC to Exit!\n" );
 
    while( !( kbhit && (getkey()==ESC_KEY) ) )
    {
         LedSet(0x05);                //LED点亮/熄灭状态设置
         Delay(160);
         LedSet(0x0a);                //LED点亮/熄灭状态设置
         Delay(160);
    }
    rINTMSK = BIT_GLOBAL ;        //disable INT
}
rPCONG 查看手册中找到,它是配置(PCONG 0x01D20040 R/W Configures the pins of port G)的地址,也就是用来配置44b0这个脚的功能使用,这些脚根据不同的值来确定不同的功能:
PCONG Bit Description
PG7 [15:14] 00 = Input 01 = Output 10 = IISLRCK 11 = EINT7
PG6 [13:12] 00 = Input 01 = Output 10 = IISDO 11 = EINT6
PG5 [11:10] 00 = Input 01 = Output 10 = IISDI 11 = EINT5
PG4 [9:8] 00 = Input 01 = Output 10 = IISCLK 11 = EINT4
PG3 [7:6] 00 = Input 01 = Output 10 = nRTS0 11 = EINT3
PG2 [5:4] 00 = Input 01 = Output 10 = nCTS0 11 = EINT2
PG1 [3:2] 00 = Input 01 = Output 10 = VD5 11 = EINT1
PG0 [1:0] 00 = Input 01 = Output 10 = VD4 11 = EINT0
0x3f<<10 也就是把eint5-eint7置位
PG[7:0] [7:0] 0: the pull up resistor attached to the corresponding port pin is enabled.
1: the pull up resistor is disabled.
D[15:0] pin pull-up resistor can be controlled by the SPUCR register.
rEXTINT = rEXTINT & (~(0xfff<<20)) ;                //EINT567低电平触发中断
EINT7 [30:28] Setting the signaling method of the EINT7.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT6 [26:24] Setting the signaling method of the EINT6.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT5 [22:20] Setting the signaling method of the EINT5.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT4 [18:16] Setting the signaling method of the EINT4.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT3 [14:12] Setting the signaling method of the EINT3.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT2 [10:8] Setting the signaling method of the EINT2.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT1 [6:4] Setting the signaling method of the EINT1.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
EINT0 [2:0] Setting the signaling method of the EINT0.
000 = Low level interrupt 001 = High level interrupt
01x = Falling edge triggered 10x = Rising edge triggered
11x = Both edge triggered
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/66822/showart_724907.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP