微波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>>

if(PdownCount >

Between[18] = PC1>>

if(PdownCount >

Between[18] = PF1>>

if((CPT_c[0]>99)||(CPT_c[1]>12)||(CPT_c[2]>

if((CPT_c[3]>99)||(CPT_c[4]>12)||(CPT_c[5]>

if((CPT_c[6]>99)||(CPT_c[7]>12)||(CPT_c[8]>

if((FPT_c[0]>99)||(FPT_c[1]>12)||(FPT_c[2]>

if((FPT_c[3]>99)||(FPT_c[4]>12)||(FPT_c[5]>

if((FPT_c[6]>99)||(FPT_c[7]>12)||(FPT_c[8]>

uf1[3]/10;

TL = time_buf1[3]%10;

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

number_disp (1,0,0x96,1,0xc8,0xd5); //日

TH = time_buf1[4]/10;

TL = time_buf1[4]%10;

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

number_disp (0,1,0x86,1,0xca,0xb1); //时

TH = time_buf1[5]/10;

TL = time_buf1[5]%10;

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

number_disp (0,1,0x88,1,0xb7,0xd6); //分

TH = time_buf1[6]/10;

TL = time_buf1[6]%10;

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

number_disp (0,1,0x8a,1,0xc3,0xeb); //秒

for (j = 0;j<6;j++)

{

keybuffer[j] = time_buf1[j+1];

}

}

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

}break;

case 0: //显示故障状态

{

string_disp (1,0,0x90,12,run5);

string_disp (0,1,0x85,12,run8);

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

}break;

default:break;

}

}

if(ADsend)

{

ADsend = 0;

if(ADcount == 1)

{

filter();

ADC1= (sum/(N-2));

if(ADC1<5)

{

ADC1 = 0;

}

a = (long)7500*ADC1/1021; //放大10倍,为了送显示小数点

VT = a; //

ADC0CN |=0x10; //写ADC0BUSY位启动转换

AMX0P = 0x06; //下一个转换通道P30

AD0EN = 1;

}

if(ADcount == 2)

{

filter();

ADC2= (sum/(N-2));

a = (long)4000*ADC2/1021; //放大10倍,为了送显示

AT = a;

a =(long)VT*AT/10000; //放大10倍的功率,单位KW

PT = a;

ADC0CN |=0x10; //写ADC0BUSY位启动转换

AMX0P = 0x08; //下一个转换通道P26

AD0EN = 1;

}

if(ADcount == 3)

{

filter();

ADC3= (sum/(N-2));

ADC0CN |=0x10; //写ADC0BUSY位启动转换

AMX0P = 0x09; //下一个转换通道P34

AD0EN = 1;

}

if(ADcount == 4)

{

filter();

ADC4= (sum/(N-2));

ADC0CN |=0x10; //写ADC0BUSY位启动转换

AMX0P = 0x05; //下一个转换通道P35

AD0EN = 1;

}

}

}

}

void UART0_ISR(void) interrupt 4

{

static uchar Rcv;

if(RI0)

{

Rcv = SBUF0;

RI0 =0;

}

/*if(Rcv == 0x7E) //

{

i = 1;

buffer[0] = Rcv;

}

else

{

if(i < 13) //12个字节

{

buffer[i] = Rcv;

i++;

}

} */

}

/*void TIME2_ISR (void) interrupt 5

{

TF2H = 0; //清标志位

count1++;

if(count1 ==5)

{

count1 = 0;

}

} */

void ADC0_ISR (void) interrupt 10

{

static uchar count; // Loop counter

AD0INT = 0; //清中断标志位

switch( AMX0P ) //通道转换

{

case 0x05: //P2.6

ADCbuffer1[count]=ADC0;

count++;

ADC0CN |=0x10; //写ADC0BUSY位启动转换

if (count > N-1){

count = 0;

AD0EN = 0; //禁止转换

ADcount = 1;

}

break;

case 0x06: //P3.0

ADCbuffer1[count]=ADC0;

count++;

ADC0CN |=0x10; //写ADC0BUSY位启动转换

if (count > N-1){

count = 0;

AD0EN = 0;

ADcount = 2;

}

break;

case 0x08: //P3.4

ADCbuffer1[count]=ADC0;

count++;

ADC0CN |=0x10; //写ADC0BUSY位启动转换

if (count > N-1){

count = 0;

AD0EN = 0;

ADcount = 3;

}

break;

case 0x09: //P3.5

ADCbuffer1[count]=ADC0;

count++;

ADC0CN |=0x10; //写ADC0BUSY位启动转换

if (count > N-1){

count = 0;

AD0EN = 0;

ADcount = 4;

}

break;

default:break;

}

}

//-----------------------------------------------------------------------------

//TIMER3中断

//-----------------------------------------------------------------------------

void Timer3_ISR(void) interrupt 14

{

static uchar i,j,k;

TMR3CN &=~(0x80); //清标志位

count++;

i++;

j++;

if(count == 8) //200ms

{

count = 0;

ADsend = 1; //开始进行AD处理标志

Tset++;

if(Tset>5)

{

Tset = 0;

}

}

if(i==20)

{

i = 0;

Disptime = 1;

}

if(j==39) //1秒误差累积;正常是40

{

j = 0;

PDD = 1; //一秒时间到,开始计算功率

if(BGset)

{

k++;

if(k>240) //4分钟关背光

{

k=0;

BGset = 0;

}

}

}

}

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

网站地图

Top