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

==4) //读时间

{

DE485 = 1;

Delay(5);

SCI1send (0x01); //站号

SCI1send (0x52); //读命令

SCI1send (0x0B); //11号地址

SCI1send (0x06); //6个地址

SCI1send (0x64);

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

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

//asm(nop);

}

}

if(ReadTimeFlag)

{

ReadTimeFlag = 0;

if(RR ==1)

{

Delay(10);

DE485 = 1;

Ds1302_Read_Time();

asm(nop);

SendSum = (0x6a+Pchange+Failure+ADC1L+ADC1H+ADC2L+ADC2H+P0H+P0L+P1H+P1L+

time_buf1[1]+time_buf1[2]+time_buf1[3]+time_buf1[4]+time_buf1[5]+time_buf1[6]+

MW4L+MW4H+MW5L+MW5H+MW6L+MW6H+MW7L+MW7H+MW8L+MW8H+MW9L+MW9H); //累加和

SCI1send (0x01); //站号

SCI1send (0x57); //写命令

SCI1send (0x00); //首地址

SCI1send (0x12); //18个地址

SCI1send (ADC1H); //MW0高位 电压

SCI1send (ADC1L); //MW0低位

SCI1send (ADC2H); //MW1 电流

SCI1send (ADC2L);

SCI1send (P0H); //MW2 实时功率

SCI1send (P0L);

SCI1send (P1H); //MW3

SCI1send (P1L);

SCI1send (MW4H); //MW4

SCI1send (MW4L);

SCI1send (MW5H); //MW5 当前充电电量(一天累计)

SCI1send (MW5L);

SCI1send (MW6H); //MW6

SCI1send (MW6L);

SCI1send (MW7H); //MW7 当前放电电量(一次累计)

SCI1send (MW7L);

SCI1send (MW8H); //MW8 当前放电电量(一次累计)

SCI1send (MW8L);

SCI1send (MW9H); //MW9 当前放电电量(一次累计)

SCI1send (MW9L);

SCI1send (0x00); //MW10 充放电指示00:放电;FF:充电

SCI1send (Pchange);

SCI1send (0x00); //MW11开始为时间

SCI1send (time_buf1[1]);

SCI1send (0x00);

SCI1send (time_buf1[2]);

SCI1send (0x00);

SCI1send (time_buf1[3]);

SCI1send (0x00);

SCI1send (time_buf1[4]);

SCI1send (0x00);

SCI1send (time_buf1[5]);

SCI1send (0x00);

SCI1send (time_buf1[6]);

SCI1send (0x00); //MW17 过压过流指示

SCI1send (Failure);

SCI1send (SendSum);

asm(nop);

Delay(100);

SendSum = 0x7d+MW21H+MW21L+MW22H+MW22L+MonthC1+DateC1+MW25H+MW25L+MW26L+MW26H+MonthC2+DateC2

+MW29H+MW29L+MW30H+MW30L+MonthF1+DateF1+MW33L+MW33H+MW34H+MW34L+MonthF2+DateF2;

SCI1send (0x01); //站号

SCI1send (0x57); //写命令

SCI1send (0x15); //21号地址

SCI1send (0x10); //16个地址

SCI1send (MW21H); //MW21高位

SCI1send (MW21L); //MW21低位

SCI1send (MW22H); //MW22

SCI1send (MW22L);

SCI1send (0x00); //月 MW23

SCI1send (MonthC1);

SCI1send (0x00); //日 MW24

SCI1send (DateC1);

SCI1send (MW25H); //MW25

SCI1send (MW25L);

SCI1send (MW26H); //MW26

SCI1send (MW26L);

SCI1send (0x00); //MW27

SCI1send (MonthC2);

SCI1send (0x00); //MW28

SCI1send (DateC2);

SCI1send (MW29H); //MW29

SCI1send (MW29L);

SCI1send (MW30H); //MW30

SCI1send (MW30L);

SCI1send (0x00); //MW31

SCI1send (MonthF1);

SCI1send (0x00); //MW32

SCI1send (DateF1);

SCI1send (MW33H); //MW33

SCI1send (MW33L);

SCI1send (MW34H); //MW34

SC

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

网站地图

Top