微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于飞思卡尔DZ60的AD 1302 KEY 485 CAN FLASH LCD程序

基于飞思卡尔DZ60的AD 1302 KEY 485 CAN FLASH LCD程序

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

#define DI1 PTGD_PTGD2 //外触发1----->

#define DI2 PTED_PTED5 //外触发2----->

#define DI3 PTED_PTED4 //外触发3----->

#define DI4 PTED_PTED3 //外触发4----->

#define JDQ1 PTCD_PTCD4 //继电器1----->

#define JDQ2 PTAD_PTAD5 //继电器2----->

#define JDQ3 PTBD_PTBD5 //继电器3----->

#define JDQ4 PTAD_PTAD6 //继电器4----->

#define JDQ5 PTBD_PTBD6 //继电器5----->

#define DE485 PTED_PTED2 //485 T R切换----->

if ( value_buf[i]>

if(MonthC1>

minutes=((ReadValue&0x70)>>

day=((ReadValue&0x70)>>

year=((ReadValue&0x70)>>

if(MonthC2>

nian=((temp&0x70)>>

if(nian>

if(MonthC3>

*p = time_buf1[2];

WEEP();

p=(byte *)(0x1522);

*p = time_buf1[3];

WEEP();

p=(byte *)(0x1523);

*p = MW6L;

WEEP();

p=(byte *)(0x1524);

*p = MW6H;

WEEP();

p=(byte *)(0x1525);

*p = MW7L;

WEEP();

p=(byte *)(0x1526);

*p = MW7H;

WEEP();

}

}

}

if(Pchange == 0x01) //如果充电

{

PupCount++; //秒累加

P3 =P3+P; //秒功率累加

Pup = (long)P3/3600; //实际放电功率,按小时计算

BetweenH = Pup>>16;

BetweenL = Pup&0xffff;

MW5H = BetweenH>>8;

MW5L = BetweenH&255;

MW4H = BetweenL>>8;

MW4L = BetweenL&255;

if(PupCount >T)

{

PupCount = 0; //超过半个小时开始写入EEPROM

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

{

MonthC3 = time_buf1[2];

DateC3 = time_buf1[3];

CBETW0L = MW4L;

CBETW0H = MW4H;

CBETW1L = MW5L;

CBETW1H = MW5H;

p=( unsigned char *)(0x1420); //指定地址

*p=0x01;

FCMD=0x40; //擦除命令

FSTAT_FCBEF=1; //启动命令

Delay(1);

while(FSTAT_FCCF==0); //等待完成

if(FSTAT_FACCERR==1)

FSTAT_FACCERR=1;

p=(byte *)(0x1420); //指定地址

*p = 0x01;

WEEP();

p=(byte *)(0x1421);

*p = time_buf1[2];

WEEP();

p=(byte *)(0x1422);

*p = time_buf1[3];

WEEP();

p=(byte *)(0x1423);

*p = MW4L;

WEEP();

p=(byte *)(0x1424);

*p = MW4H;

WEEP();

p=(byte *)(0x1425);

*p = MW5L;

WEEP();

p=(byte *)(0x1426);

*p = MW5H;

WEEP(); //如果相等则认为是当前时间,继续

}

}

}

asm(nop);

ADch_s = 3;

ADCSC1=0x63;

}

if(ADcount == 3)

{

filter();

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

ADC3H = (sum/(N-2))>>8;

ADC3L = (sum/(N-2))&255;

ADch_s = 4;

ADCSC1=0x64;

}

if(ADcount == 4)

{

filter();

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

ADC4H = (sum/(N-2))>>8;

ADC4L = (sum/(N-2))&255;

ADch_s = 19;

ADCSC1=0x73;

}

if(RR ==2)

{

DE485 = 1;

Delay(2);

SCI1send (0x01); //站号

SCI1send (0x52); //读命令

SCI1send (0x14); //20号地址判断ENT键状态

SCI1send (0x01); //1个地址

SCI1send (0x68);

Delay(1); //必须加段延时确保数据发送出去

DE485 = 0; //485切换到接收状态

asm(nop);

}

if(RR ==3)

{

DE485 = 1;

Delay(2);

SCI1send (0x01); //站号

SCI1send (0x57); //写命令

SCI1send (0x14); //20号地址清零

SCI1send (0x01); //1个长度

SCI1send (0x00); //18号地址

SCI1send (0x00);

SCI1send (0x6D);

Delay(50);

RR =4;

}

if(RR

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

网站地图

Top