你的电路有很多问题
RESET 端口 连接138会使他一直复位。
A0,A1 端口 连接138会使他不能选择。
- #include <reg52.h>
- #include <absacc.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define PA XBYTE[0x8000]
- #define PB XBYTE[0x8100]
- #define PC XBYTE[0x8200]
- #define CR XBYTE[0x8300] //命令口
- sbit A8255_Rst=P3^5;
- void delay(unsigned int n)
- {
- unsigned int i=0,j=0;
- for(i=0;i<n;i++)
- {
- for(j=0;j<120;j++);
- }
- }
- void display()
- {
- uchar i=0, outdata=0;
- for(i=0;i<8;i++)
- {
- outdata=~(0x01<<i);
- PB=outdata;
- delay(1000);
- }
- }
- void main()
- {
- A8255_Rst=1;
- A8255_Rst=0;
- CR = 0x80; //Set control byte for PA = out, PB = out, PC = out.
- //P2=0x80;
- while(1)
- {
- display();
- }
- }
复制代码
|