#include
#define uchar unsigned char
#define uint unsigned int
#define add 0xaa
__config(0x3b31);
const uchar ee_data[]={1,2,3,4,5,6};
uchar read_data[6];
const uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(uint x);
void init();
void didi(uchar num);
void disp(uchar num1,uchar num2,uchar num3,uchar num4,uchar num5,uchar num6);
void write();
void read();
void main()
{
init();
write();
delay(100);
read();
while(1)
{
disp(read_data[0],read_data[1],read_data[2],read_data[3],read_data[4],read_data[5]);
}
}
void delay(uint x)
{
uint a,b;
for(a=x;a》0;a--)
for(b=110;b》0;b--);
}
void init()
{
trisd=0;
trisa=0;
trise0=0;
//adcon1=0x07;
re0=0;
portd=0;
porta=0;
trisc=0xff;
sspstat=0x80;
sspcon=0x38;
sspcon2=0;
sspadd=0x09;
}
void write()
{
uchar i;
sspif=0;
sen=1;
while(!sspif);
sspif=0;
sspbuf=0xa0;
while(!sspif);
sspif=0;
sspbuf=add;
while(!sspif);
sspif=0;
for(i=0;i《6;i++)
{
sspbuf=ee_data[i];
while(!sspif);
sspif=0;
}
pen=1;
while(!sspif);
sspif=0;
}
void read()
{
uchar i;
sspif=0;
sen=1;
while(!sspif);
sspif=0;
sspbuf=0xa0;
while(!sspif);
sspif=0;
sspbuf=add;
while(!sspif);
sspif=0;
sspif=0;
rsen=1;
while(!sspif);
sspif=0;
sspbuf=0xa1;
while(!sspif);
sspif=0;
for(i=0;i《6;i++)
{
rcen=1;
while(!sspif);
read_data[i]=sspbuf;
while(!sspif);
sspif=0;
if(i》=5)
{
ackdt=1;
}
else
{
ackdt=0;
}
acken=1;
while(!sspif);
sspif=0;
}
pen=1;
while(!sspif);
sspif=0;
}
void didi(uchar num)
{
uchar di_num;
for(di_num=num;di_num》0;di_num--)
{
re0=1;
delay(50);
re0=0;
delay(20);
}
}
本文引用地址: http://www.21ic.com/app/mcu/201812/786472.htm
void disp(uchar num1,uchar num2,uchar num3,uchar num4,uchar num5,uchar num6)
{
portd=table[num1];//显示第一个数码管
porta=0x20;//0010 0000
delay(2);
portd=table[num2];//显示第二个数码管
porta=0x10;//0001 0000
delay(2);
portd=table[num3];//显示第三个数码管
porta=0x08;//0000 1000
delay(2);
portd=table[num4];//显示第四个数码管
porta=0x04;//0000 0100
delay(2);
portd=table[num5];//显示第五个数码管
porta=0x02;//0000 0010
delay(2);
portd=table[num6];//显示第六个数码管
porta=0x01;//0000 0001
delay(2);
}
Masimo展示先进的无创患者监测技术
将AI和机器人技术整合到强调远程医疗的护理交付框架中
驻极体话筒和电容话筒区别
米家电动剃须刀S301实测分析
中国自主标准移动多媒体数字电视全功能产品现身
如何正确的使用PIC单片机内部的IIC通信
什么是直流稳压电源?为什么需要直流稳压电源?直流稳压器的典型用途?
电池过流保护片的工作原理
HRC副总裁熊飞:将儿时的汽车梦变现
朝鲜推出金达莱7手机,具有生物识别技术
如何做一个高集成低能耗的BMS系统
让物质发挥作用-让智能家居更智能
2021年人工智能和机器学习的5个发展趋势
人工智能入门的三道门槛
华为新一代折叠屏手机是如何炼成的?
华硕ZenFlip UX370即将来袭,谍照美翻了
Maxwell储能电容的节能应用探讨
农药残留检测仪器设备的功能及参数
地下水PH电导率传感器在线监测
区块链5.0的价值及其应用