#include "reg51.h" #include "absacc.h" #define pa XBYTE[0x0000] //8255A口地址设置 #define pb XBYTE[0x0100] //8255B口地址设置 #define pc XBYTE[0x0200] //8255C口地址设置 #define con XBYTE[0x0300] //8255控制字端口地址设置 sbit p3_4 = P3^4; unsigned char t=0x0, n; void delay(unsigned int j) //延时程序 { unsigned int i; for(i = 0 ;i <200;i++) for(j = 0 ;j <200;j++); } void Init() //初始化8255 { con = 0x82; } void kg() //开关控制D1-D6的亮灭 { t = pb; t = ~t; pa = t; } void lm() //中断0控制亮灭 { EA = 1; EX0 = 1; IT0 = 1; pa = t; } void jishu() //T1计数 { TMOD = 0x55; EA = 1; TH0 = 0xff; TL0 = 0xff; ET0 = 1; TR0 = 1; } void jishu1() //T1计数,方法2(暂时无效) { EA = 1; ET0 = 1; TMOD = 0x05; TH0 = 0x00; TL0 = 0x00; TR0 = 1; } void lsd() //流水灯 { unsigned int temp,i; temp = 0x01; for(i = 0;i < 8;i++){ pa = temp; temp = temp<<1; delay(200); } } void main() { pa = 0x00; } void zd() interrupt 0 { t = ~t; } void js() interrupt 1 { n++; pa = n; TH0 = 0xff; TL0 = 0xff; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)