#include "N76E003.h"
#include "intrins.h"
#define A P07
#define B P15
#define C P00
#define D P02
#define E P04
#define F P30
#define G P10
#define DP P01
#define GG P16
#define SS P17
#define BB P05
#define GG1 P12
#define SS1 P13
#define BB1 P14
unsigned char xs_js;
unsigned char data_bw;
unsigned char data_sw;
unsigned char data_gw;
unsigned char data_bw1;
unsigned char data_sw1;
unsigned char data_gw1;
unsigned int data_dy1;
unsigned int data_dy;
unsigned int data_ad;
unsigned char xs_delay;
unsigned char k;
void dk_init()
{
CKEN=0x20;
CKSWT=0x00;
CKDIV=0x00;
CKCON=0x00;
P0M1=0x48;
P0M2=0x00;
P1M1=0x02;
P1M2=0x00;
P3M1=0x00;
P3M2=0x00;
}
void tim0_init()
{
EA=0;
ET0=0;
TMOD=0x22;
TH0=0x64;
TL0=0x00;
TF0=0;
TR0=0;
ES=0;
ET1=0;
EX1=0;
EX0=0;
EADC=0;
EBOD=0;
WDCON=0x00;
ADCCON0=0x03;
ADCCON1=0x01;
}
void dy_cl()
{
data_sw=data_dy/100;
data_gw=data_dy%100/10;
}
void xs_cl()
{
GG=1;SS=1;BB=1;GG1=1;SS1=1;BB1=1;
switch(xs_js)
{
case 0:BB=0;break;
case 1:SS=0;break;
case 2:GG=0;break;
case 3:BB1=0;break;
case 4:SS1=0;break;
case 5:GG1=0;break;
}
A=0;B=0;C=0;D=0;E=0;F=0;G=0;DP=0;
switch(xs_js)
{
case 0:if(data_bw==0){A=1;B=1;C=1;D=1;E=1;F=1;break;}
else if(data_bw==1){B=1;C=1;break;}
else if(data_bw==2){A=1;B=1;D=1;E=1;G=1;break;}
else if(data_bw==3){A=1;B=1;C=1;D=1;G=1;break;}
else if(data_bw==4){B=1;C=1;F=1;G=1;break;}
else if(data_bw==5){A=1;C=1;D=1;F=1;G=1;break;}
else if(data_bw==6){A=1;C=1;D=1;E=1;F=1;G=1;break;}
else if(data_bw==7){A=1;B=1;C=1;break;}
else if(data_bw==8){A=1;B=1;C=1;D=1;E=1;F=1;G=1;break;}
else if(data_bw==9){A=1;B=1;C=1;D=1;F=1;G=1;break;}
case 1:if(data_sw==0){A=1;B=1;C=1;D=1;E=1;F=1;DP=1;break;}
else if(data_sw==1){B=1;C=1;DP=1;break;}
else if(data_sw==2){A=1;B=1;D=1;E=1;G=1;DP=1;break;}
else if(data_sw==3){A=1;B=1;C=1;D=1;G=1;DP=1;break;}
else if(data_sw==4){B=1;C=1;F=1;G=1;DP=1;break;}
else if(data_sw==5){A=1;C=1;D=1;F=1;G=1;DP=1;break;}
else if(data_sw==6){A=1;C=1;D=1;E=1;F=1;G=1;DP=1;break;}
else if(data_sw==7){A=1;B=1;C=1;DP=1;break;}
else if(data_sw==8){A=1;B=1;C=1;D=1;E=1;F=1;G=1;DP=1;break;}
else if(data_sw==9){A=1;B=1;C=1;D=1;F=1;G=1;DP=1;break;}
case 2:if(data_gw==0){A=1;B=1;C=1;D=1;E=1;F=1;break;}
else if(data_gw==1){B=1;C=1;break;}
else if(data_gw==2){A=1;B=1;D=1;E=1;G=1;break;}
else if(data_gw==3){A=1;B=1;C=1;D=1;G=1;break;}
else if(data_gw==4){B=1;C=1;F=1;G=1;break;}
else if(data_gw==5){A=1;C=1;D=1;F=1;G=1;break;}
else if(data_gw==6){A=1;C=1;D=1;E=1;F=1;G=1;break;}
else if(data_gw==7){A=1;B=1;C=1;break;}
else if(data_gw==8){A=1;B=1;C=1;D=1;E=1;F=1;G=1;break;}
else if(data_gw==9){A=1;B=1;C=1;D=1;F=1;G=1;break;}
case 3:if(data_bw1==0){B=1;A=1;D=1;C=1;G=1;F=1;break;}
else if(data_bw1==1){A=1;D=1;break;}
else if(data_bw1==2){B=1;A=1;C=1;G=1;E=1;break;}
else if(data_bw1==3){B=1;A=1;D=1;C=1;E=1;break;}
else if(data_bw1==4){A=1;D=1;F=1;E=1;break;}
else if(data_bw1==5){B=1;D=1;C=1;F=1;E=1;break;}
else if(data_bw1==6){B=1;D=1;C=1;G=1;F=1;E=1;break;}
else if(data_bw1==7){B=1;A=1;D=1;break;}
else if(data_bw1==8){B=1;A=1;D=1;C=1;G=1;F=1;E=1;break;}
else if(data_bw1==9){B=1;A=1;D=1;C=1;F=1;E=1;break;}
case 4:if(data_sw1==0){B=1;A=1;D=1;C=1;G=1;F=1;DP=1;break;}
else if(data_sw1==1){A=1;D=1;DP=1;break;}
else if(data_sw1==2){B=1;A=1;C=1;G=1;E=1;DP=1;break;}
else if(data_sw1==3){B=1;A=1;D=1;C=1;E=1;DP=1;break;}
else if(data_sw1==4){A=1;D=1;F=1;E=1;DP=1;break;}
else if(data_sw1==5){B=1;D=1;C=1;F=1;E=1;DP=1;break;}
else if(data_sw1==6){B=1;D=1;C=1;G=1;F=1;E=1;DP=1;break;}
else if(data_sw1==7){B=1;A=1;D=1;DP=1;break;}
else if(data_sw1==8){B=1;A=1;D=1;C=1;G=1;F=1;E=1;DP=1;break;}
else if(data_sw1==9){B=1;A=1;D=1;C=1;F=1;E=1;DP=1;break;}
case 5:if(data_gw1==0){B=1;A=1;D=1;C=1;G=1;F=1;DP=1;break;}
else if(data_gw1==1){A=1;D=1;break;}
else if(data_gw1==2){B=1;A=1;C=1;G=1;E=1;break;}
else if(data_gw1==3){B=1;A=1;D=1;C=1;E=1;break;}
else if(data_gw1==4){A=1;D=1;F=1;E=1;break;}
else if(data_gw1==5){B=1;D=1;C=1;F=1;E=1;break;}
else if(data_gw1==6){B=1;D=1;C=1;G=1;F=1;E=1;break;}
else if(data_gw1==7){B=1;A=1;D=1;break;}
else if(data_gw1==8){B=1;A=1;D=1;C=1;G=1;F=1;E=1;break;}
else if(data_gw1==9){B=1;A=1;D=1;C=1;F=1;E=1;break;}
}
xs_js++;
if(xs_js>5) xs_js=0;
}
void delay(unsigned int z)
{
unsigned int x;
unsigned int y;
for(x=z;x>0;x--)
for(y=500;y>0;y--);
}
void main()
{
dk_init();
tim0_init();
while(1)
{
data_dy=0;
for(k=0;k<10;k++)
{
ADCS=1;
while(ADCS !=1);
data_ad=(ADCRH<<4)+ADCRL;
data_dy=data_dy+data_ad;
}
data_dy=data_dy/10;
data_dy=data_dy/3.91;
if(data_dy>990)
{
data_dy=990;
}
xs_delay++;
if(xs_delay>=20)
{
xs_delay=0;
dy_cl();
}
delay(20);
xs_cl();
}
} |