发表于:2010/11/30 0:21:08
#0楼
源程序基本如下:
uchar incept_data[2]={0,0};
uchar i=0;
void main()
{
display1();//power on display message
delay_ms(50);
display3();//set the parameter display message
init();//permit int0,the beep is work when short current
while(1)
{
if(!parameter)//we must change the message in the (),in order to change mode-->>set?test?
{
delay(80);
init_uart();//transsion message
}
current(); //display current
delay_us(100); //wait AD change,this is must
}
}
void display1()//power on display message
{
;;;;;
}
void display3()///set the parameter display message
{
;;;;;
}
void dis()//0
{uchar a;
switch(incept_data[1])
{
case 1://wave
{lcd_wcom(0x80);
for(a=0;a<5;a++)
lcd_wdat(c11[a]);
delay_us(200);
};
break;
case 2://bias
{lcd_wcom(0x80+0x0a);
for(a=10;a<15;a++)
lcd_wdat(c11[a]);
delay_us(200);
};
break;
default: ;break;
}
}
void wave()//1
{
lcd_wcom(0x80+0x05);
switch(incept_data[1])
{case 1:lcd_wdat(0x41);break;
case 2:lcd_wdat(0x42);break;
case 3:lcd_wdat(0x51);break;
default:;break;
}
}
void bias()//2
{lcd_wcom(0x80+0x11);
switch(incept_data[1])
{case 2:lcd_wdat(0x32);break;
case 3:lcd_wdat(0x33);break;
//......
default:;break;
}
}
void current()
{int i;
char t;
TEMP_cur(filter());
lcd_wcom1(0x80+0x5d);
for(i=0;i<5;i++)
{t=c3[i];
lcd_wdat1(t);
}
}
//---启动AD转换并读结果///////
unsigned int ReadAD(void)
{
uchar H,L,i;
uint count;
cs=0;
addelay();
sclk=1;
sclk=0;
H=0;
for(i=0;i<=3;i++)
{
sclk=1;
if(dout) H++;
sclk=0;
if(i!=3)
H<<=1;
}
L=0;
for(i=0;i<8;i++)
{
sclk=1;
if(dout) L++;
sclk=0;
if(i!=7)
L<<=1;
}
addelay();
cs=1;
count=0;
count=(unsigned int)(H<<8)|L;
return count;
}
//////////////////software filter ,average filter///////////////////////////
unsigned int filter()
{
;;;;;
}
//---------------------------this is use the inturrpt to alarm------------------
void init(void)
{
IT0=0;
EA=1;
EX0=1;
}
void ist_int0(void) interrupt 0
{
delay_us(10);
if(note==0)
{alarm();
current(); //display current
delay_us(100);
}
}
//-----------------------------this is the intrrupt to receive data-----------------------
void init_uart(void)
{
SCON=0x50;
TMOD=0x20;
TL1=0xfa;
TH1=0xfa;
PCON=0x00;
TR1=1;
ES=1;
EA=1;
}
void uart(void) interrupt 4
{
if(RI==1)
{
RI=0;
incept_data[i]=SBUF;
i++;
if(i>1){
i=0;
if(i==0)
switch(incept_data[0])
{
case 0xb1:
dis();break;
case 0xa1:
wave();break;
case 0xa2:
bias();break;
default: ;break;
}
write_add(incept_data[0],0xa0);
delay_ms(100);
}
}
}
我想把bias();dis();wave()参数分别存放在24C存储器中,不知道read_add 和 write_add放在哪个地方?也就是多个参数的存储与写入,如有朋友能带上参考,万分感谢!
uchar incept_data[2]={0,0};
uchar i=0;
void main()
{
display1();//power on display message
delay_ms(50);
display3();//set the parameter display message
init();//permit int0,the beep is work when short current
while(1)
{
if(!parameter)//we must change the message in the (),in order to change mode-->>set?test?
{
delay(80);
init_uart();//transsion message
}
current(); //display current
delay_us(100); //wait AD change,this is must
}
}
void display1()//power on display message
{
;;;;;
}
void display3()///set the parameter display message
{
;;;;;
}
void dis()//0
{uchar a;
switch(incept_data[1])
{
case 1://wave
{lcd_wcom(0x80);
for(a=0;a<5;a++)
lcd_wdat(c11[a]);
delay_us(200);
};
break;
case 2://bias
{lcd_wcom(0x80+0x0a);
for(a=10;a<15;a++)
lcd_wdat(c11[a]);
delay_us(200);
};
break;
default: ;break;
}
}
void wave()//1
{
lcd_wcom(0x80+0x05);
switch(incept_data[1])
{case 1:lcd_wdat(0x41);break;
case 2:lcd_wdat(0x42);break;
case 3:lcd_wdat(0x51);break;
default:;break;
}
}
void bias()//2
{lcd_wcom(0x80+0x11);
switch(incept_data[1])
{case 2:lcd_wdat(0x32);break;
case 3:lcd_wdat(0x33);break;
//......
default:;break;
}
}
void current()
{int i;
char t;
TEMP_cur(filter());
lcd_wcom1(0x80+0x5d);
for(i=0;i<5;i++)
{t=c3[i];
lcd_wdat1(t);
}
}
//---启动AD转换并读结果///////
unsigned int ReadAD(void)
{
uchar H,L,i;
uint count;
cs=0;
addelay();
sclk=1;
sclk=0;
H=0;
for(i=0;i<=3;i++)
{
sclk=1;
if(dout) H++;
sclk=0;
if(i!=3)
H<<=1;
}
L=0;
for(i=0;i<8;i++)
{
sclk=1;
if(dout) L++;
sclk=0;
if(i!=7)
L<<=1;
}
addelay();
cs=1;
count=0;
count=(unsigned int)(H<<8)|L;
return count;
}
//////////////////software filter ,average filter///////////////////////////
unsigned int filter()
{
;;;;;
}
//---------------------------this is use the inturrpt to alarm------------------
void init(void)
{
IT0=0;
EA=1;
EX0=1;
}
void ist_int0(void) interrupt 0
{
delay_us(10);
if(note==0)
{alarm();
current(); //display current
delay_us(100);
}
}
//-----------------------------this is the intrrupt to receive data-----------------------
void init_uart(void)
{
SCON=0x50;
TMOD=0x20;
TL1=0xfa;
TH1=0xfa;
PCON=0x00;
TR1=1;
ES=1;
EA=1;
}
void uart(void) interrupt 4
{
if(RI==1)
{
RI=0;
incept_data[i]=SBUF;
i++;
if(i>1){
i=0;
if(i==0)
switch(incept_data[0])
{
case 0xb1:
dis();break;
case 0xa1:
wave();break;
case 0xa2:
bias();break;
default: ;break;
}
write_add(incept_data[0],0xa0);
delay_ms(100);
}
}
}
我想把bias();dis();wave()参数分别存放在24C存储器中,不知道read_add 和 write_add放在哪个地方?也就是多个参数的存储与写入,如有朋友能带上参考,万分感谢!