📄 12864串口.c
字号:
}
//***********************************************************************
//***********************************************************************
//高低位互换
void Invert(void)
{
u08 i=0,j;
b_data=g;
switch(g)
{
case 1: j=7; break;
case 3: j=6; break;
case 7: j=5; break;
case 15: j=4; break;
case 31: j=3; break;
case 63: j=2; break;
case 127: j=1; break;
}
for (i=0;i<j;i++)
{
b_data=(b_data<<1);
}
}
//***********************************************************************
//***********************************************************************
//
void delay11(u16 aaa)
{
while (aaa!=0)
aaa--;
}
//***********************************************************************
//***********************************************************************
//温度采集,显示 OK
void stc_ad(void)
{
u08 tmp;
if (stc_ad_b==0)
{
stc_ad_time++;
if (stc_ad_time!=2000) return;
ADC_CONTR=0xe7; //选择P1.7作为A/D转换通道,如转换通道要加延时20US~200US
ADC_CONTR|=0x08; //启动AD转换
stc_ad_b=1;
return;
}
tmp=ADC_CONTR;
tmp&=0x10;
if (tmp==0) return;
stc_ad_b=0;
ADC_CONTR&=0xe7;
if (temp_eer==1)
{
temp_eer1=1;
return;
}
if (temp_eer1==1) //恢复温度显示
{
temp_eer_play(tab9); //初始化温度显示区信息
temp_eer1=0;
hex_to_bcd(temp_data); //
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
}
tmp=tab8[ADC_DATA];
// hex_to_bcd(ADC_DATA); //显示实时所采集的数据
hex_to_bcd(tmp); //显示温度转换后的数据
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,16);
}
//**********************************************************************
//**********************************************************************
//故障处理 程序ok
void eer_to(void)
{
if (eer1==0)
{
u08 i;u32 j;
chn_disp (tab5);
led_chao=1;
power_run=0;
time_60s_b =0;
time_exte_b=0;
temp_out_b=0; //关加热
temp_out=1; //关加热
con_disp (0x00,0x00,0x94,0x90,15);//------
con_disp (0x00,0x00,0x95,0x90,15);//
con_disp (0x00,0x00,0x96,0x90,15);//
con_disp (0x00,0x00,0x97,0x90,15);//
con_disp (0x00,0x00,0x8e,0x80,15);//清反白
con_disp (0x00,0x00,0x8f,0x80,15);//
con_disp (0x00,0x00,0x9c,0x90,15);//
con_disp (0x00,0x00,0x9d,0x90,15);//
con_disp (0x00,0x00,0x9e,0x90,15);//------
for (i=0;i<30;i++)
{
beep=1;
for (j=0;j<50000;j++){}
beep=0;
for (j=0;j<50000;j++){}
}
while (eer1==1)
{
chn_disp (tab7);
ISP_CONTR=0x20;
}
}
if (eer2==0)
{
u08 i;u32 j;
chn_disp (tab6);
led_chao=1;
power_run=0;
time_60s_b =0;
time_exte_b=0;
temp_out_b=0; //关加热
temp_out=1; //关加热
con_disp (0x00,0x00,0x94,0x90,15);//------
con_disp (0x00,0x00,0x95,0x90,15);//
con_disp (0x00,0x00,0x96,0x90,15);//
con_disp (0x00,0x00,0x97,0x90,15);//
con_disp (0x00,0x00,0x8e,0x80,15);//清反白
con_disp (0x00,0x00,0x8f,0x80,15);//
con_disp (0x00,0x00,0x9c,0x90,15);//
con_disp (0x00,0x00,0x9d,0x90,15);//
con_disp (0x00,0x00,0x9e,0x90,15);//------
for (i=0;i<30;i++)
{
beep=1;
for (j=0;j<50000;j++){}
beep=0;
for (j=0;j<50000;j++){}
}
while (eer2==1)
{
chn_disp (tab7);
ISP_CONTR=0x20;
}
}
}
//**********************************************************************
void key_to_clr(void)
{
if (menu!=0)
{
if (key_to_clr_time>=1000000)
{
key_to_clr_time=0;
menu=0;
con_disp (0x00,0x00,0x94,0x90,15);//------
con_disp (0x00,0x00,0x95,0x90,15);//
con_disp (0x00,0x00,0x96,0x90,15);//
con_disp (0x00,0x00,0x97,0x90,15);//
con_disp (0x00,0x00,0x8e,0x80,15);//清反白
con_disp (0x00,0x00,0x8f,0x80,15);//
con_disp (0x00,0x00,0x9c,0x90,15);//
con_disp (0x00,0x00,0x9d,0x90,15);//
con_disp (0x00,0x00,0x9e,0x90,15);//------
return;
}
key_to_clr_time++;
}
}
//**********************************************************************
//温度输出控制
void temp_to(void)
{
if (ADC_DATA<temp_out_l)
{
temp_out_b=0;
temp_out=1; //关加热
if (temp_eer==0)
{
if (menu==2) menu=0;
con_disp (0x00,0x00,0x8e,0x80,15);
con_disp (0x00,0x00,0x8f,0x80,15);
beep=1;beep_x=temp_eer_bemp;beep_temp=0;
temp_eer_play(tab4);
temp_eer=1;
}
return;
}
if (ADC_DATA>temp_out_h)
{
temp_out_b=0;
temp_out=1; //关加热
if (temp_eer==0)
{
if (menu==2) menu=0;
con_disp (0x00,0x00,0x8e,0x80,15);
con_disp (0x00,0x00,0x8f,0x80,15);
beep=1;beep_x=temp_eer_bemp;beep_temp=0;
temp_eer_play(tab4);
temp_eer=1;
}
return;
}
if (tab8[ADC_DATA]>=temp_data)
{
temp_out_b=0;
temp_out=1; //关加热
temp_eer=0;
return;
}
if (temp_data-tab8[ADC_DATA]>=stc_ad_x)
{
temp_eer=0;
if (temp_eer1==0)
{
temp_out_b=1;
temp_out=0; //开加热
}
return;
}
}
//**********************************************************************
//**********************************************************************
//分计数信号
void time_60s(void)
{
if (time_60s_b==1)
{
if (TF1==1)
{
TL1=0xbf; //
TH1=0x63; // 20ms
TR1=1; //
TF1=0;
time_60s_to++;
time_60_s++;
//------------------------------------------------
//走时光标闪 0.5s
if (time_60_s==25)
{
con_disp (0xff,0x00,0x95,0x90,15);
if (time_60s_data>9) con_disp (0x00,0xff,0x94,0x90,15);
if (time_60s_data>99) con_disp (0xff,0xff,0x94,0x90,15);
}
if (time_60_s>=50)
{
time_60_s=0;
con_disp (0x00,0x00,0x94,0x90,15);
con_disp (0x00,0x00,0x95,0x90,15);
}
//-------------------------------------------------
if (time_60s_to>=3000) //分计时
{
time_60s_to=0;
time_60s_data--;
if (time_60s_data!=0)
{
hex_to_bcd(time_60s_data); //温度设置数据
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
return;
}
time_60s_data=time_data;
hex_to_bcd(time_60s_data); //温度设置数据
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
time_exte_b1=0;
power_out=1;
power_run=0;
led_chao=1;
time_60s_b=0;
beep=1;beep_x=20;beep_temp=0;
}
}
}
}
//***********************************************************************
//***********************************************************************
//定时器初始化
void TInit(void)
{
TMOD = 0x11; //T0定时T1采集
TL1=0xbf; //
TH1=0x63; // 20ms
TR1=1; //
}
//***********************************************************************
//***********************************************************************
//外控
void time_exte_run(void)
{
if (time_exte_b1==0)
{
if (time_exte_b==0)
{
if (time_exte==0)
{
time_exte_play(tab2);//play
th0_xx=0xe6;//定时器高位数值
tl0_xx=0xff;
led_chao=0;
power_run=1;
beep=1;beep_x=1;beep_temp=0;
time_60s_b=0;
time_exte_b=1;
}
return;
}
if (time_exte==1)
{
if (time_exte_b==1)
{
th0_xx=0xe6;//定时器高位数值
tl0_xx=0xff;
led_chao=1;
power_run=0;
beep=1;beep_x=1;beep_temp=0;
time_60s_b =0;
time_exte_b=0;
time_exte_play(tab3);
hex_to_bcd(time_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
}
return;
}
}
}
//***********************************************************************
//***********************************************************************
//
void main(void)
{
u08 sss=0x98;
//----------------------
P1M0|=0x80; //p1.7脚配置ad功能
P1M1|=0x00; //
ADC_DATA=0;
ADC_CONTR|=0x80; //开A/D转换电源
ADC_CONTR=0xe7; //选择P1.7作为A/D转换通道,如转换通道要加延时20US~200US
//----------------------
th0_xx=0xe6;//定时器高位数值
tl0_xx=0xff;
th0_x=0xe6;//定时器高位数值
tl0_x=0xfF;
th0_x1=0xe6;//定时器高位数值
tl0_x1=0xfF;
ADC_CONTR=0xe7; //选择P1.7作为A/D转换通道,如转换通道要加延时20US~200US
ADC_CONTR|=0x08; //启动AD转换
delay11 (50000);
beep=0;
init_lcd (); //LED初始化
delay11 (50000);
lat_disp (0x00,0x00); //清LED DRAM区
delay11 (50000);
img_disp (bmp3);//启动界面
delay11 (50000);
//------------------------------------------------------------------
for (sss=0x98;sss<0xa0;sss++)
{
g=1;
while(g!=0xff)
{
Invert();
con_disp1 (b_data,0x00,sss,0x8f,16);
g=g*2+1;
delay11 (50000);
delay11 (50000);
}
con_disp1 (0xff,0x00,sss,0x8f,16);
g=1;
while(g!=0xff)
{
Invert();
con_disp1 (0xff,b_data,sss,0x8f,16);
g=g*2+1;
delay11 (50000);
delay11 (50000);
}
con_disp1 (0xff,0xff,sss,0x8f,16);
}
ADC_CONTR=0xe7; //选择P1.7作为A/D转换通道,如转换通道要加延时20US~200US
ADC_CONTR|=0x08; //启动AD转换
//-------------------------------------------------------------------
lat_disp (0x00,0x00);
chn_disp (tab1);
TInit();
IT0=1;ET0=1;EX0=1;EA=1;TR0=0;
beep=1;beep_x=2;beep_temp=0;
//---------------------------------------------------------------------
//初始化片内 EEPROM
if (EepromRead (0x2a00)!=0x55)
{
EepromClr(0x2a00);
EepromWrite(0x2a00,0x55);
EepromClr(0x2800);
EepromWrite(0x2800,0x55);
EepromWrite(0x28fd,0x32); //time
EepromWrite(0x28fe,0x32); //temp
EepromWrite(0x28ff,0x32); //power
}
if (EepromRead (0x2800)!=0x55)
{
EepromClr(0x2a00);
EepromWrite(0x2a00,0x55);
EepromClr(0x2800);
EepromWrite(0x2800,0x55);
EepromWrite(0x28fd,0x32); //time
EepromWrite(0x28fe,0x32); //temp
EepromWrite(0x28ff,0x32); //power
}
stc_eeprom_add=0x2800;
stc_rw_inc=0;
while (EepromRead (stc_eeprom_add)==0x55)
{
stc_eeprom_add++;
stc_rw_inc++;
}
stc_rw_inc--;
stc_r_add=stc_rw_inc*3;
stc_eeprom_add=0x28ff-stc_r_add-2;
time_data= EepromRead (stc_eeprom_add);
stc_eeprom_add++;
temp_data= EepromRead (stc_eeprom_add);
stc_eeprom_add++;
power_data= EepromRead (stc_eeprom_add);
if (stc_rw_inc!=0)
{
EepromClr(0x2800);
EepromWrite(0x2800,0x55);
EepromWrite(0x28fd,time_data); //time
EepromWrite(0x28fe,temp_data); //temp
EepromWrite(0x28ff,power_data); //power
}
stc_rw_inc=0;
//---------------------------------------------------------------------
//-------------------------------------------------------------
//温度显示初始化
// temp_data=1;
hex_to_bcd(temp_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
//-------------------------------------------------------------
//功率显示初始化
// power_data=50;
hex_to_bcd(power_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,13);
//-------------------------------------------------------------
//时间显示初始化
// time_data=100;
hex_to_bcd(time_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
//-------------------------------------------------------------
//计数时间显示初始化
time_60s_data=time_data;
hex_to_bcd(time_60s_data); //温度设置数据
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
//-------------------------------------------------------------
switch(power_data)
{
case 10:
th0_x1=0xe6; //定时器高位数值
tl0_x1=0xff;
break;
case 20:
th0_x1=0xe9; //定时器高位数值
tl0_x1=0x7f;
break;
case 30:
th0_x1=0xec; //定时器高位数值
tl0_x1=0x00;
break;
case 40:
th0_x1=0xee; //定时器高位数值
tl0_x1=0x7f;
break;
case 50:
th0_x1=0xf1; //定时器高位数值
tl0_x1=0x00;
break;
case 60:
th0_x1=0xf3; //定时器高位数值
tl0_x1=0x7f;
break;
case 70:
th0_x1=0xf6; //定时器高位数值
tl0_x1=0x00;
break;
case 80:
th0_x1=0xf8; //定时器高位数值
tl0_x1=0x80;
break;
case 90:
th0_x1=0xfb; //定时器高位数值
tl0_x1=0x00;
break;
case 100:
th0_x1=0xff; //定时器高位数值
tl0_x1=0x80;
break;
}
//--------------------------------------------------------------
while(1)
{
if (eer1==1)
{
if (eer2==1)
{
fkey(); //按键处理
play_t(); //反白处理
power_tt(); //调功处理
time_60s();
stc_ad();
time_exte_run();
temp_to();
key_to_clr();
}
}
eer_to();
beep_out(); //beep处理
}
}
//----------------------------------------------
//调功输出程序
void dengpao(void) interrupt 0
{
if (power_to==1) if (power_run==1) power_out=0; //功率100直接输出
if (power_run==0) return; //调功缓起标志,未开调功直接退出
TL0=tl0_xx; //读取功率设置值
TH0=th0_xx; //
TR0=1;
}
void time0(void) interrupt 1
{
if(power_k==1)
{
TR0=0;
if (power_to==0) power_out=1;
TL0=tl0_xx;
TH0=th0_xx;
power_k=0;
// temp_out=1; //关温度控制
return;
}
TH0=0xf8; //设置关闭脉冲宽度
TL0=0x30; //
power_out=0; //调功输出
power_k=1; //
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -