Chinaunix首页 | 论坛 | 博客
  • 博客访问: 102506
  • 博文数量: 31
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 430
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-18 11:29
文章分类

全部博文(31)

文章存档

2011年(1)

2010年(1)

2009年(2)

2008年(27)

我的朋友

分类: LINUX

2008-06-03 16:17:33

前几天看了下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

阅读(1327) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~