微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于C8051F的AD UART0 KEY FLASH TIME3程序

基于C8051F的AD UART0 KEY FLASH TIME3程序

时间:12-01 来源:互联网 点击:

if(BGset>

if(k>

if(Page>

if(!(Mkey&0x08)) //SW5按下吗?右移->

if(direction >

if(keybuffer[0]>

if(Tset>

if(keybuffer[1]>

if(Tset>

if(keybuffer[2]>

if(Tset>

if(keybuffer[3]>

if(Tset>

if(keybuffer[4]>

if(Tset>

if(keybuffer[5]>

if(Tset>

Between[18] = PC1>>

Between[18] = PF1>>

//保存至FLASH

}

}

if(PDD)

{

PDD = 0;

if(Runstate == 0xb7) //如果充电

{

PdownCount++; //秒累加

PT1 = PT1+PT; //秒累计的功率,

PC1 = PT1/3600; //实际充电功率,按小时计算,注意此时累计电量为实际的10倍,为了送小数显示

if(PdownCount > T) //超过半个小时开始写入EEPROM

{

PdownCount = 0;

for(j=0;j<20;j++) //先读出FLASH里的时间

{

Between[j]=CPT_c[j];

}

if((time_buf1[2] == Between[10])&& (time_buf1[3] == Between[11])) //当前时间等于缓存时间,继续写入缓存

{

Between[18] = PC1>>8;

Between[19] = PC1&255;

Flash_Program_CTP(); //写功率和时间到FLASH

}

}

}

if(Runstate == 0xc8) //如果放电

{

PdownCount++; //秒累加

PT2 = PT2+PT; //秒累计的功率

PF1 = PT2/3600; //实际放电功率,按小时计算,,注意此时累计电量为实际的10倍,为了送小数显示

if(PdownCount > T) //超过半个小时开始写入EEPROM

{

PdownCount = 0;

for(j=0;j<20;j++) //先读出FLASH里的时间

{

Between[j]=FPT_c[j];

}

if((time_buf1[2] == Between[10])&& (time_buf1[3] == Between[11])) //当前时间等于缓存时间,继续写入缓存

{

Between[18] = PF1>>8;

Between[19] = PF1&255;

Flash_Program_FTP(); //写功率和时间到FLASH

}

}

}

}

if(Disptime)

{

Disptime = 0;

Ds1302_Read_Time();

if(Page!=Page1)

{

clrram (); //如果页面变化,需要清屏;

}

switch(Page)

{

case 1: //画面1:显示当前电压电流

{

string_disp (1,0,0x80,10,tab1); //显示电压

string_disp (1,0,0x90,10,tab2); //显示电流

string_disp (0,1,0x80,10,tab3); //显示功率

string_disp (0,1,0x90,10,tab4);

if(Runstate == 0xa6)string_disp (0,1,0x96,4,run1); //显示停机

if(Runstate == 0xb7)string_disp (0,1,0x96,4,run2); //显示充电

if(Runstate == 0xc8)string_disp (0,1,0x96,4,run3); //显示放电

if(Runstate == 0xd9)string_disp (0,1,0x96,4,run4); //显示故障

TH= VT/1000; //拆分送显示千位

TL = (VT%1000)/100; //拆分送显示百位

TT1 = ((VT%1000)%100)/10; //拆分送显示十位

TT2 = ((VT%1000)%100)%10; //拆分送显示个位

if(!TH)

{

TH = 10;

if(!TL)

{

TL = 10;

}

}

number_disp (1,0,0x85,1,TAB[TH],TAB[TL]); //电压送显示

number_disp (1,0,0x86,1,TAB[TT1],0x2E);

number_disp (1,0,0x87,1,TAB[TT2],0x20);

number_disp (1,0,0x88,1,0x56,0x20);

TH= AT/1000; //拆分送显示千位

TL = (AT%1000)/100; //拆分送显示百位

TT1 = ((AT%1000)%100)/10; //拆分送显示十位

TT2 = ((AT%1000)%100)%10; //拆分送显示个位

if(!TH) //高位为零,灭零处理

{

TH = 10;

if(!TL)

{

TL = 10;

}

}

number_disp (1,0,0x95,1,TAB[TH],TAB[TL]); //电流送显示

number_disp (1,0,0x96,1,TAB[TT1],0x2E);

number_disp (1,0,0x97,1,TAB[TT2],0x20);

number_disp (1,0,0x98,1,0x41,0x20);

TH= PT/1000; //拆分送显示千位

TL = (PT%1000)/100; //拆分送显示百位

TT1 = ((PT%1000)%100)/10; //拆分送显示十位

TT2 = ((PT%1000)%100)%10; //拆分送显示个位

if(!TH) //高位为零,灭零处理

{

TH = 10;

if(!TL)

{

TL = 10;

}

}

number_disp (0,1,0x85,1,TAB[TH],TAB[TL]); //功率送显示

number_disp (0,1,0x86,1,TAB[TT1],0x2E);

number_disp (0,1,0x87,1,TAB[TT2],0x4B);

number_disp (0,1,0x88,1,0x57,0x20);

Page1=Page; //保存当前页面值

}break;

case 2:

{

string_disp (1,0,0x80,12,run6);

string_disp (0,1,0x80,12,run7);

Pchange(PC1);

number_disp (1,0,0x94,1,TAB[TH],TAB[TL]);

number_disp

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top