阅读:1037回复:1
中断程序请教
98下的中断程序如下:
#include <dos.h> #include <conio.h> void set_int(unsigned int data); void enint(void); //void interrupt (*oldhandler1)(__CPPARGS); void interrupt Com2(); int Test; void set_int(unsigned int data) { unsigned char daH = (unsigned char)((data>>8)&0x00ff); unsigned char daL = (unsigned char)(data&0x00ff); outportb(0x22c,0x10); outportb(0x22b,0x76); outportb(0x229,daL); outportb(0x229,daH); } void enint(void) { disable(); // oldhandler1=getvect(0x0b); setvect(0x0b,Com2); enable(); } void OpenCom2(void) { unsigned char ch; disable(); ch = inportb(0x21)&0xf7; /* = com2 ; &0xef = com1 */ outportb(0x21,ch); enable(); } void interrupt Com2(void) { puts(\"int occur\"); outportb(0x20,0x20); Test = 0; } void main(void) { //clrcsr(); enint(); set_int(1843); OpenCom2(); while(1) { }; } 用Driverworks 设计的程序如下: 应用程序 Set_int(); 调用驱动程序下的 Set_int():其实现如下: PULONG pBuf = (PULONG)I.IoctlBuffer(); t<<\"in the Setup_int\\n\"; ULONG step = *pBuf; WRITE_PORT_UCHAR((PUCHAR)0x22C,0x10); WRITE_PORT_UCHAR((PUCHAR)0x22B,0x76); WRITE_PORT_UCHAR((PUCHAR)0x229,(UCHAR)(step&0x00ff)); WRITE_PORT_UCHAR((PUCHAR)0x229,(UCHAR((step>>8&0x00ff)); UCHAR ch = READ_PORT_UCHAR((PUCHAR)0x21); ch = ch&0xf7; WRITE_PORT_UCHAR((PUCHAR)0x21,ch); 驱动程序inf文件下:设置IRQNUM=3,(把COM2屏蔽了) 就是产生不了中断,请问这程序哪里有问题,应该怎么改?谢谢了 |
|
沙发#
发布于:2005-03-14 20:11
怎么没人回?上面是dos下的中断程序,现在要在2k下,把它改写成驱动程序,下面是wdm驱动程序的一部分(用来启动中断)。这是一个定时中断程序,驱动程序按照应用程序给的中断频率产生中断。
|
|