2019-03-24 19:26发布
void main(){ lcd_init(); //液晶初始化 at24c02_init(); //AT24C02初始化 time0[0]=at24c02_read_add(1); time0[1]=at24c02_read_add(2); time0[2]=at24c02_read_add(3); time0[3]=at24c02_read_add(4); time0[4]=at24c02_read_add(5); time0[5]=at24c02_read_add(6); time0[6]=at24c02_read_add(7); //time0[ ]里面存着我初始化的值,年月日时分秒星期,但是第一次上电后,time0[ ]数组从AT24C02读出来是不是没东西啊???
set_ds1302(); //初始化函数,显示年月日时分秒
while(1) { keyscan(); //正常走时键盘扫描 alarmkeyscan(); //闹钟键盘扫描 if(helt==0&&alarmflag==0)//helt=0时正常运行,helt=1时,由于进行时间调整,所以跳过读取ds1302数据这部分,直接扫描键盘党调整好之后又令helt=0; { read_rtc() ; //读取DS1302地址中的数 date_pros(); //对读取出来的BCD码进行数据处理,转化成10进制 display(); //数据处理好之后显示出来
time0[0]=year; time0[1]=week; time0[2]=mon; time0[3]=day; time0[4]=hour; time0[5]=min; time0[6]=sec; //每改变一秒,都将它写入time0数组中 at24c02_write_add(1,time0[0]); at24c02_write_add(2,time0[1]); at24c02_write_add(3,time0[2]); at24c02_write_add(4,time0[3]); at24c02_write_add(5,time0[4]); at24c02_write_add(6,time0[5]); at24c02_write_add(7,time0[6]);//并将改变好的值写入AT24C02中 } /************一下判断是否到闹钟时间**************/ if((hour==alarmhour)&&(min==alarmmin)) { // beep=0; led=0; } else { led=1; } }} //我这样写好后,液晶显示的是乱码,要是我把set_ds1302(); 写到数组前面的话也不行,刚开始总会读取time0[ ]里面的数 怎么办呢?该怎么整好呢 ? 谁有高招帮帮忙
最多设置5个标签!
void main()
{
lcd_init(); //液晶初始化
at24c02_init(); //AT24C02初始化
time0[0]=at24c02_read_add(1);
time0[1]=at24c02_read_add(2);
time0[2]=at24c02_read_add(3);
time0[3]=at24c02_read_add(4);
time0[4]=at24c02_read_add(5);
time0[5]=at24c02_read_add(6);
time0[6]=at24c02_read_add(7); //time0[ ]里面存着我初始化的值,年月日时分秒星期,但是第一次上电后,time0[ ]数组从AT24C02读出来是不是没东西啊???
set_ds1302(); //初始化函数,显示年月日时分秒
while(1)
{
keyscan(); //正常走时键盘扫描
alarmkeyscan(); //闹钟键盘扫描
if(helt==0&&alarmflag==0)//helt=0时正常运行,helt=1时,由于进行时间调整,所以跳过读取ds1302数据这部分,直接扫描键盘党调整好之后又令helt=0;
{
read_rtc() ; //读取DS1302地址中的数
date_pros(); //对读取出来的BCD码进行数据处理,转化成10进制
display(); //数据处理好之后显示出来
time0[0]=year;
[ 本帖最后由 Learner_new 于 2012-2-8 13:21 编辑 ]time0[1]=week;
time0[2]=mon;
time0[3]=day;
time0[4]=hour;
time0[5]=min;
time0[6]=sec; //每改变一秒,都将它写入time0数组中
at24c02_write_add(1,time0[0]);
at24c02_write_add(2,time0[1]);
at24c02_write_add(3,time0[2]);
at24c02_write_add(4,time0[3]);
at24c02_write_add(5,time0[4]);
at24c02_write_add(6,time0[5]);
at24c02_write_add(7,time0[6]);//并将改变好的值写入AT24C02中
}
/************一下判断是否到闹钟时间**************/
if((hour==alarmhour)&&(min==alarmmin))
{
// beep=0;
led=0;
}
else
{
led=1;
}
}
}
//我这样写好后,液晶显示的是乱码,要是我把set_ds1302(); 写到数组前面的话也不行,刚开始总会读取time0[ ]里面的数 怎么办呢?该怎么整好呢 ? 谁有高招帮帮忙
一周热门 更多>