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

else

{

MW6L = 0;

MW6H = 0;

MW7L = 0;

MW7H = 0;

P1 = 0;

}

}

EnableInterrupts; //开中断

for(;;)

{

__RESET_WATCHDOG(); //喂内部看门狗

if(!DI1)

{ //充电

Pchange = 0x01;

} //放电

if(!DI2)

{

Pchange = 0x02;

}

if(DI1&&DI2)

{

Pchange = 0; //停机状态

}

if(Pchange==0x02)

{

if((time_buf1[2] != MonthF3)|| (time_buf1[3] != DateF3)) //只要是 时间不等,就要把当前记录写入EEPROM,开始新的计算

{

p=( unsigned char *)(0x1500); //指定地址 缓存的时间写入前1天,前一天的时间写入前1天前1天

*p=0x01;

FCMD=0x40; //擦除命令

FSTAT_FCBEF=1; //启动命令

Delay(1);

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

if(FSTAT_FACCERR==1)

FSTAT_FACCERR=1;

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

*p = 0x01;

WEEP();

p=(byte *)(0x1501);

*p = MonthF2;

WEEP();

p=(byte *)(0x1502);

*p = DateF2;

WEEP();

p=(byte *)(0x1503);

*p = MW33L;

WEEP();

p=(byte *)(0x1504);

*p = MW33H;

WEEP();

p=(byte *)(0x1505);

*p = MW34L;

WEEP();

p=(byte *)(0x1506);

*p = MW34H;

WEEP();

p=( unsigned char *)(0x1510); //指定地址 //缓存的时间写入前1天,前一天的时间写入前1天前1天

*p=0x01;

FCMD=0x40; //擦除命令

FSTAT_FCBEF=1; //启动命令

Delay(1);

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

if(FSTAT_FACCERR==1)

FSTAT_FACCERR=1;

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

*p = 0x01;

WEEP();

p=(byte *)(0x1511); //如果时间变了,原缓存存入前一天的内存

*p = MonthF3;

WEEP();

p=(byte *)(0x1512);

*p = DateF3;

WEEP();

p=(byte *)(0x1513);

*p = FBETW0L;

WEEP();

p=(byte *)(0x1514);

*p = FBETW0H;

WEEP();

p=(byte *)(0x1515);

*p = FBETW1L;

WEEP();

p=(byte *)(0x1516);

*p = FBETW1H;

WEEP();

P1 = 0;

MW29L = MW33L;

MW29H = MW33H;

MW30L = MW34L;

MW30H = MW34H;

MonthF1 = MonthF2;

DateF1 = DateF2;

MW33L = FBETW0L;

MW33H = FBETW0H;

MW34L = FBETW1L;

MW34H = FBETW1H;

MonthF2 = MonthF3;

DateF2 = DateF3;

asm(nop);

MonthF3 =time_buf1[2]; //当前时间送入缓存

DateF3= time_buf1[3];

//MonthF3 = time_buf1[2];

//DateF3 = time_buf1[3];

FBETW0L = MW6L;

FBETW0H = MW6H;

FBETW1L = MW7L;

FBETW1H = MW7H;

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

*p=0x01;

FCMD=0x40; //擦除命令

FSTAT_FCBEF=1; //启动命令

Delay(1);

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

if(FSTAT_FACCERR==1)

FSTAT_FACCERR=1;

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

*p = 0x01;

WEEP();

p=(byte *)(0x1521);

*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) //充电的时候

{

if((time_buf1[2] != MonthC3)|| (time_buf1[3] != DateC3)) //只要时间不等,开始新的计算

{

p=( unsigned char *)(0x1400); //指定地址 缓存的时间写入前1天,前一天的时间写入前1天前1天

*p=0x01;

FCMD=0x

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

网站地图

Top