|
/*******´®ÐÐÊý¾ÝÔËÓõÄʵÑé***** */
#include
#include //_nop_()ÒýÓÃ
#define uint unsigned int
#define uchar unsigned char
unsigned int dsp_send,cont_send,temp,lo,km;
uchar cont_tr;
uint cont_fe;
uchar cont_urat, dsp_contr,dsp_modn,aa,bai,shi,ge,ge,com_js,conk,key;//??5?????
bit number_sys=0;
sbit dulb=P2^6;
sbit duls=P2^7;
sbit dulg=P3^7 ;
#define bdata flag;
sbit cufa=P2^2;
sbit zhen=P2^1;
sbit fan= P2^0;
sbit key_cont=P2^5;
sbit dxbh_jb = P2^3;
sbit ua_indata =P1^7; //74HC595-14 sdA ´®ÐÐÊäÈë
sbit st_cp_data =P1^6; //74hc595-12 SLCK Ëø´æÆ÷ʱÖÓ ¸ßµçƽÓÐЧ
sbit sh_cp_data =P1^5; //74HC595-11 SCLK ¼Ä´æÆ÷Ëø´æʱÖÓ ¸ßµçƽÓÐЧ
sbit mr_re_data =P1^4; //74HC595-10 CLR ¼Ä´æÆ÷¸´Î» µÍµçƽÓÐЧ
sbit oe_ontcontre_data =P1^3; //74HC595-13 ¸ßµçƽΪÎÞÊä³ö¸ß×è̬£¬µÍµçƽʱQ1-Q7ÓÐÊä³öÖµ
sfr ISP_DATA = 0xe2;
sfr ISP_ADDRH = 0xe3;
sfr ISP_ADDRL = 0xe4;
sfr ISP_CMD = 0xe5;
sfr ISP_TRIG = 0xe6;
sfr ISP_CONTR = 0xe7;
sfr AUXR=0X8E;
sfr WDT_CONTR=0Xe1; //¿´ÃŹ· 85D D5 N 61 E
sfr P1M0=0x91;
sfr P1M1=0x92;
sfr P3M0=0XB1;
sfr P3M1=0XB2;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f,0x5f,0x7c,0x58,0x5e,0x7b,0x71,0x00,0x40};
void display_data (uchar bai,uchar shi,uchar ge) ;
void key_contme (void);
void init();
void delay(uint);
void delay(uint boms)
{
uint froma,lites; //Âýµã¿ÉÒÔ¿´Ç幤×÷¹ý³Ì
for(froma=130;froma>0;froma--)
for(lites=boms;lites>0;lites--);
}
//·¢ËÍÏÔʾ//
void display(uint datal)
{
uchar b;
for(b=0;b<8;b++)
{
st_cp_data=0; //ÔÚÊý¾Ýµ½À´Ö®Ç°ÏÈÀ´Ò»¸öµÍµçƽ
sh_cp_data=0; //ÔÚÊý¾Ýµ½À´Ö®Ç°ÏÈÀ´Ò»¸öµÍµçƽ
if(datal&0x80) //Èç¹ûÊÕµ½µÄÊý¾ÝÓë-0x8000ÏàÓë µÄ½á¹ûΪ1/ 1000 0000
{
ua_indata=1;
}
else
{
ua_indata=0;
}
datal<<=1; //½«ÊÕµ½µÄÊý¾ÝÏò×óÒƶ¯Ò»Î»ºó¼Ä´æµ½datalÖÐ ´ËʱµÄdatalµÄÖµÊǵÈÓÚ½øÐÐÒÆλºóµÄÖµÁË,ÿ×óÒÆÒ»´ÎºóÓұߵÄ0¿ªÊ¼Ôö¶à
//ai_esp_datal();//°ÑÊÕµ½µÄOºÍ1½øÐÐÖØл¹ÔΪÔÓÐÊý¾Ý
sh_cp_data=1; //Ëø´æµ½¼Ä´æ÷
}
st_cp_data=1; //Ëø´æס
return ;
}
void main(void)
{
uint x,y;
init();
for(x=0;x<18;x++)
{
y++;
display_data(table[y],table[y],table[y]);
}
while(1)
{
if(!cufa)
{
cont_send=30000;
while((!cufa)&&(--cont_send));
{
ge++;
display_data(17,17,17);
}
key_contme();
}
else
display_data(ge,shi,bai);
}
}
void timer0() interrupt 1//???0????
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20) //1s
{
aa=0;
temp++;
}
if(temp==dsp_send)
zhen=0;
if(temp==cont_urat)
zhen=1;
if(temp==dsp_contr)
fan=0;
if(temp==dsp_modn)
fan=1;
if(temp>=dsp_modn==134)display_data(17,17,17);
if(temp==134) {TR0=0;TR1=0;EA=0; }
bai=temp/100;
shi=temp%100/10;
ge=temp%10;
}
void init()//?????,
{
cont_send=300;
dsp_send=0;
temp=0;
TMOD=0x11;
cont_urat=ua_indata=0;
km=0;
lo=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=0;
ET0=1;
TR0=0;
IT0=1;
dulg=1;
duls=1;
dulb=1;
}
void display_data (uchar ge,uchar shi,uchar bai )
{
display(table[shi]);
dulg=0;
delay(50); //ÉÁ˸¸ÐºÍÁÁ¶È£¬
dulg=1;
delay(20);//µÈ´ýÊý¾ÝÈ«²¿·¢ËÍÍê
display(table[ge]);
duls=0;
delay(50);
duls=1;
delay(20); //ÏûÒþ
display(table[bai]);
dulb=0;
delay(50);
dulb=1;
delay(20);
}
void key_contme (void)
{
if((cufa==0)&&(number_sys==0))
{
delay(10);
if(!cufa);delay(10);
if(!cufa)//°´Ïºó¾Í¿ªÊ¼¼ÆÊý£¬È·¶¨°´Ï¼üµÄʱ¼ä³¤Óë¶Ì
{
TR0=0;
TR1=0;
EA=0;
cont_send=300;
while((!cufa)&&(--cont_send));// Á½±ßµÄÌõ¼þÏàͬʱ£¬ÈçËÉ¿ªÊÖÁË£¬Í¬Ê±DSP_SEND»¹Ã»ÓÐΪ0.»òÕß°´¼ü°´ÏÂÖУ¬DSP£ßSEND¼õÍêΪ£°ÁË
{
delay(100); //300X100=30000MS
delay(200);
}
if(cont_send)//°´¼üÄ©³¬¹ýÈýÃ룮ֻÊDzÙ×÷ÕßÌáÇ°ËÉÊÖÁË
{
temp++;
dsp_send++;
cont_urat=dsp_send+10;
dsp_contr=20+cont_urat;
dsp_modn=dsp_contr+10;
}
else
{
TR0=1;
TR1=1;
EA=1;
delay(200);
aa=0;
temp=0;
}
}
number_sys=0;
}
}
上面的代码,原想在按下键以后,显示___线,再进入正常显示状态,可是得到的却是另外一个结果.望高人修正一下.
三片74HC595串行显示计数值,当按照 个位,十位,百位的顺序进行发送数据发现;个位的显示却跑到十位的位置上来显示,调整无效果,线路连接也没问题,单独测试个位,十位,百位的连线没问题,可以单独控制显示个位,十位,百位,三个位都正常.最后所以找不到原因,
|
|