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

40; //擦除命令

FSTAT_FCBEF=1; //启动命令

Delay(1);

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

if(FSTAT_FACCERR==1)

FSTAT_FACCERR=1;

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

*p = 0x01;

WEEP();

p=(byte *)(0x1401);

*p = MonthC2;

WEEP();

p=(byte *)(0x1402);

*p = DateC2;

WEEP();

p=(byte *)(0x1403);

*p = MW25L;

WEEP();

p=(byte *)(0x1404);

*p = MW25H;

WEEP();

p=(byte *)(0x1405);

*p = MW26L;

WEEP();

p=(byte *)(0x1406);

*p = MW26H;

WEEP();

p=( unsigned char *)(0x1410); //指定地址 缓存的时间写入前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 *)(0x1410); //指定地址

*p = 0x01;

WEEP();

p=(byte *)(0x1411);

*p = MonthC3;

WEEP();

p=(byte *)(0x1412);

*p = DateC3;

WEEP();

p=(byte *)(0x1413);

*p = CBETW0L;

WEEP();

p=(byte *)(0x1414);

*p = CBETW0H;

WEEP();

p=(byte *)(0x1415);

*p = CBETW1L;

WEEP();

p=(byte *)(0x1416);

*p = CBETW1H;

WEEP();

MW21L = MW25L;

MW21H = MW25H;

MW22L = MW26L;

MW22H = MW26H;

MonthC1 = MonthC2;

DateC1 = DateC2;

MW25L = CBETW0L;

MW25H = CBETW0H;

MW26L = CBETW1L;

MW26H = CBETW1H;

MonthC2 = MonthC3;

DateC2 = DateC3;

P3 = 0;

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

DateC3= time_buf1[3];

//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();

}

}

if(!RR)

{

Ds1302_Write_Time();

Delay(10);

T20 = 1;

}

if(T20) //切换到2界面

{

T20 = 0;

TENT = 0;

DE485 = 1; //保证切换到发射

Delay(200);

SCI1send (0x01); //站号

SCI1send (0x57); //写命令

SCI1send (0x12); //18号地址跳转页面指令,跳转到1界面

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

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

SCI1send (0x01);

SCI1send (0x6c);

Delay(100); //需加一段长延时

SCI1send (0x01); //站号

SCI1send (0x57); //写命令

SCI1send (0x12); //18号地址跳转页面指令,跳转到2界面

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

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

SCI1send (0x02);

SCI1send (0x6d);

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

RR = 1; //1分钟内ENT没有按下,转回正常模式

asm(nop);

}

if(ADSET) //处理AD;

{

ADSET = 0;

if

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

网站地图

Top