8255总线实验 编写程序利用8255扩展单片机的IO口,控制8位数码管显示1-8。
程序:
#include<reg51.h>
#include<absacc.h>
#define PORT_A XBYTE[0X7FFC]
#define PORT_B XBYTE[0X7FFD]
#define PORT_C XBYTE[0X7FFE]
#define PORT_CTL XBYTE[0X7FFF]
void delay()
{
unsigned int i;
for(i=0;i<40;i++);
}
int main(void)
{
unsigned char smg[]={0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char i=0;
unsigned char weiport[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
PORT_CTL=0x80;
while(1)
{
PORT_B=weiport[i];
PORT_A=smg[i];
i++;
if(i==8)
i=0;
delay();
}
}
视频:
https://www.bilibili.com/video/BV1zA411H7Ft/