⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wang_inta.c

📁 美国tern公司开发的嵌入式开发平台586E
💻 C
字号:
/*******************************************************************
  586_INTB.C  Test SC520 /INTB  10-6-2002                                                              *
	SC520 includes 3 Programmable Interval Timers (PIT)                                                                
	PIT0 and PIT1 works in 4 modes only, PIT2 works in all 6 modes                                                                
	P21=Master PIC IR6, interrupt vector=0x46, PIT Timer2/INTB=J3.12
===================================================================*/
#include	<dos.h>						/* Enable/disable functions */
#include "586.h"
void interrupt far intb_isr(void);
int intb_int, ledd,a,i;		/* pit interrupt flag for pit test */
#define MMCR 0xdf00
unsigned char led1[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,   //0,1,2,3,4,5
                       //0   1   2   3   4   5
                      0x7D,0x07,0x7F,0x6F,0x77,0x7C,    //6,7,8,9,A,B
                      //6   7   8   9   10  11
                      0x39,0x5E,0x79,0x71,0x73,0x3E,    //C,D,E,F,P,U
                      // 12  13  14  15  16  17
                      0x76,0x38,0x40,0x6E,0x0FF,0x00,   //H,L,-,Y, 全屏  ,'全暗'
                      //18  19  20  21  22   23
                      0x37,0x3F,0x6D,0x06,0x2F,0x6F,   //N,O,S,I,error,G,
                      //24  25  26  27  28  29
                      0x0E,0x67,0x50,0x31};             //J,Q,R,T
                      //30  31  32  33

void main(void)
{
   sc_init();
   // Connect J3.12=/INTB to J2.8=P13 as input with pullup
   for(i=2;i<27;i++){
		pio_init(i, 2); // PIO 2-26 as output
		}
	pio_init(28, 2); // PIO 28 as output
	pio_init(29, 2); // PIO 29 as output
	pio_init(30, 2); // PIO 30 as output

	disable();

//	P21=Master PIC IR6, interrupt vector=0x46, PIT Timer2/INTB=J3.12
	HLPRsetvect(0x46, (void far *) intb_isr); //将中断程序地址写入对应中断向量表中

   disable();
//	P21=Master PIC IR6, interrupt vector=0x46, PIT Timer2/INTB=J3.12
   poke(MMCR,_PCIINTBMAP_,0x15); // MAP INTB to Master IR6(P21)
	outportb(_MPICINTMSK_IO,inportb(_MPICINTMSK_IO)&0xbf); // unmask IR6 master
   poke(MMCR,_MPICMODE_,0x00);  //边沿跳变
   poke(MMCR,_INTPINPOL_,0x0000); //负跳变,由高到低

//	outportb(_MPICINTMSK_IO,inportb(_MPICINTMSK_IO)|0x40); // mask IR6 master
   enable();


	intb_int = 0; /* clear the global event flag */

while(1){
   a=led1[15]|0xfe00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);  //can not use outport command
   delay_ms(3);
	a=led1[17]|0xfd00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   a=led1[12]|0xfb00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   a=led1[18]|0xf700;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   a=led1[25]|0xef00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);

}
}

//
// intb_isr() is the Interrupt Service Routine for	/INTB
//
void interrupt far intb_isr(void)
{
	intb_int++; /* indicate that the event occured */
   for(i=0;i<10000;i++)
   {a=led1[18]|0xfe00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);  //can not use outport command
   delay_ms(3);
	a=led1[14]|0xfd00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   a=led1[19]|0xfb00;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   a=led1[19]|0xf700;
   a=a<<2;
   poke(MMCR, _PIODATA15_0_,a);
   delay_ms(3);
   }

// Issue the EOI to interrupt controller
outportb(_MPICOCW2_IO,0x66); // Specific EQI for master IR6
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -