89c51与8155做流水灯仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
8155 流水灯 Protues
8155 流水灯 Protues
8155 流水灯 Protues
单片机源程序如下:
- #include "absacc.h"
- #include "reg51.h"
- #include "intrins.h"
- #define uchar unsigned char
- #define COM8155 XBYTE[0x7ff8]
- #define PA8155 XBYTE[0x7ff9]
- #define PB8155 XBYTE[0x7FFA]
- #define PC8155 XBYTE[0x7ffB]
- sbit IO_M8155=P2^0;
- sbit RES_8155=P2^6;
- sbit CE_8155=P2^7;
- uchar outdata=0xfe;
- uchar time;
- void init_time(void);
- void init_8155(void);
- void main()
- {
- init_time();
- init_8155();
- while(1)
- {
- if(time>10)
- {
- P1=outdata;
- PB8155=outdata;
- if(PA8155&0x01&&!(PA8155&0x02))//正转
- outdata=_crol_(outdata,1);
- else;
- if(PA8155&0x02&&!(PA8155&0x01))//反转
- outdata=_cror_(outdata,1);
- else;
- time=0;
- }
- }
- }
- void time0(void)interrupt 1 using 1
- {
- time++;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- }
- void init_time(void)
- {
-
- TMOD=0x01;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- ET0=1;
- EA=1;
- TR0=1;
- }
- void init_8155(void)
- {
- //CE_8155=0;
- //IO_M8155=1;
- //RES_8155=1;
- //_nop_();
- //RES_8155=0;
- COM8155=0x02;//A输入;B输出
-
- }
复制代码
所有资料51hei提供下载:
8155流水灯.zip
(43.92 KB, 下载次数: 93)
|