寄存器宏定義_第1頁(yè)
寄存器宏定義_第2頁(yè)
寄存器宏定義_第3頁(yè)
寄存器宏定義_第4頁(yè)
寄存器宏定義_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、/*寄存器宏定義*/#define WRITE_DS1302_SECOND 0X80 /寫入“秒”寄存器#defineWRITE_DS1302_MINUTE 0X82 /寫入“分”寄存器#defineWRITE_DS1302_HOUR 0X84 /寫入“小時(shí)”寄存器#defineWRITE_DS1302_DAY 0X86 /寫入“日”寄存器#defineWRITE_DS1302_MONTH 0X88 /寫入“月”寄存器#defineWRITE_DS1302_WEEK 0X8A /寫入“星期”寄存器#defineWRITE_DS1302_YEAR 0X8C /寫入“年”寄存器#define WR

2、ITE_DS1302_REINIT_ADDR 0XC0 /寫入上電判斷RAM寄存器#defineREAD_DS1302_SECOND 0X81 /讀出“秒”寄存器#defineREAD_DS1302_MINUTE 0X83 /讀出“分”寄存器#defineREAD_DS1302_HOUR 0X85 /讀出“小時(shí)”寄存器#defineREAD_DS1302_DAY 0X87 /讀出“日期”寄存器#defineREAD_DS1302_MONTH 0X89 /讀出“月”寄存器#defineREAD_DS1302_WEEK 0X8B /讀出“星期”寄存器#defineREAD_DS1302_YEAR

3、0X8D /讀出“年”寄存器#define READ_DS1302_REINIT_ADDR 0XC1 /讀出上電判斷RAM寄存器#define WRITE_DS1302_Timing_Hour1 0XC2#define WRITE_DS1302_Timing_Min1 0XC4#define WRITE_DS1302_Timing_Hour2 0XC6#define WRITE_DS1302_Timing_Min2 0XC8 #define WRITE_MODE_STA 0XCA#define WRITE_WIN_STA 0XCC#define READ_DS1302_Timing_Hour1

4、 0XC3#define READ_DS1302_Timing_Min1 0XC5#define READ_DS1302_Timing_Hour2 0XC7#define READ_DS1302_Timing_Min2 0XC9#define READ_MODE_STA 0XCB#define READ_WIN_STA 0XCD#defineDS1302_WRITE_PROTECT 0X8E /寫保護(hù)寄存器#define DS1302_Trickl_Charge 0X90 /慢速充電寄存器/*初始化日期時(shí)間宏定義*/初始日期時(shí)間為“2011年10月09日星期日12點(diǎn)00分00秒”/ 注意:此處

5、是十進(jìn)制,下面“地址,數(shù)據(jù)發(fā)送子程序”中有轉(zhuǎn)換#define INIT_SECONGD 50#define INIT_MINUTE 59#define INIT_HOUR 22#define INIT_DAY 9#define INIT_MONTH 10#define INIT_WEEK 7#define INIT_YEAR 11/*寫保護(hù)設(shè)置宏定義*/ 注意:此處是十進(jìn)制,下面“地址,數(shù)據(jù)發(fā)送子程序”中有轉(zhuǎn)換#defineDS1302_WRITE_PROTECT_NO 0 /寫保護(hù)禁止#defineDS1302_WRITE_PROTECT_OFF 128 /寫保護(hù)允許/*DS1302端口定義

6、*/sbit DS1302_SCLK=P15; /DS1302時(shí)鐘信號(hào)sbit DS1302_DIO=P16; /DS1302數(shù)據(jù)信號(hào)sbit DS1302_CE=P17; /DS1302片選信號(hào)/*充電方式宏定義*/ TCS TCS TCS TCS DS DS RS RS/慢速充電選擇(TCS)位(位47)控制快速充電器的選擇,只有1010模式才能使慢速充電器工作/所有其它模式將禁止慢速充電器工作/DS1302上電時(shí),慢速充電器被禁止/(DS)位(位23)選擇是一個(gè)二極管(01)還是兩個(gè)二極管(10),如果DS為“00”或“11”,則充電器被禁止/RS位(位01)選擇連接在VCC2與VCC1

7、之間的電阻:“00” 無;“01” 2K; “10” 4K; “11” 8K。/如果RS為00,充電器被禁止,與TCS無關(guān)/最大充電電流計(jì)算:Imax=(5.0V-二極管壓降)/R#define Hold_DS1302_Charge 160/ =0XA5 即 1010 0101使用慢速充電器,選擇一個(gè)二極管、一個(gè)電阻/*重新上電判斷宏定義*/#define DS1302_REINIT_DATA 3/=0x55 即 0101 0101/*標(biāo)示位定義*/bit DS1302_CH_flog=0;/1302時(shí)鐘暫停標(biāo)示位 “=0”運(yùn)行 “=1”暫停bit DS1302_CLK_WAY=0;/1302

8、時(shí)鐘工作方式標(biāo)示位 “=0”24小時(shí)方式 “=1”12小時(shí)方式extern void delayms(unsigned int xms);/*地址,數(shù)據(jù)發(fā)送子程序*/void WRITE_DS1302(unsigned char addr,dat) /注意:為了方便此處的dat為十進(jìn)制unsigned char i,temp;dat=(dat/10)*16+dat%10;/十進(jìn)制轉(zhuǎn)化成十六進(jìn)制DS1302_CE=0; /沒有先前的低電平不能工作。,DS1302_CE的高電平啟動(dòng)一次數(shù)據(jù)的傳輸 DS1302_SCLK=0;DS1302_CE=1;/DS1302片選上跳變打開數(shù)據(jù)傳輸for(i=0

9、;i<8;i+) /循環(huán)8次位移DS1302_SCLK=0;temp=addr;DS1302_DIO=(bit)(temp&0x01); /每次傳送低字節(jié)addr=addr>>1; /右移一位delayms(1);DS1302_SCLK=1;for(i=0;i<8;i+) /循環(huán)8次位移DS1302_SCLK=0;temp=dat;DS1302_DIO=(bit)(temp&0x01); /每次傳送低字節(jié) dat=dat>>1; /右移一位delayms(1);DS1302_SCLK=1;DS1302_CE=0; /DS1302片選下跳變關(guān)閉

10、數(shù)據(jù)傳輸/*數(shù)據(jù)讀取子程序*/unsigned char READ_DS1302(unsigned char addr)unsigned char i,temp,dat;DS1302_CE=0; /沒有先前的低電平不能工作。,DS1302_CE的高電平啟動(dòng)一次數(shù)據(jù)的傳輸 DS1302_SCLK=0;DS1302_CE=1;/DS1302片選上跳變打開數(shù)據(jù)傳輸for(i=0;i<8;i+) /循環(huán)8次位移DS1302_SCLK=0;temp=addr;DS1302_DIO=(bit)(temp&0x01); /每次傳送低字節(jié)addr=addr>>1; /右移一位dela

11、yms(1);DS1302_SCLK=1;for(i=0;i<8;i+)if(DS1302_DIO=1)dat|=0x80;DS1302_SCLK=1;dat=dat>>1;delayms(1);DS1302_SCLK=0;DS1302_CE=0; /DS1302片選下跳變關(guān)閉數(shù)據(jù)傳輸dat=(dat/16)*10+dat%16; /十六進(jìn)制轉(zhuǎn)化成十進(jìn)制return dat; /注意:為了方便此處返回的值為十進(jìn)制/*初始化DS1302子程序*/void INIT_DS1302() if(READ_DS1302(READ_DS1302_REINIT_ADDR)!=DS1302_

12、REINIT_DATA) /判斷是否是重新上電 WRITE_DS1302(DS1302_WRITE_PROTECT,DS1302_WRITE_PROTECT_NO); /禁止寫保護(hù) WRITE_DS1302(WRITE_DS1302_SECOND,INIT_SECONGD); /秒 WRITE_DS1302(WRITE_DS1302_MINUTE,INIT_MINUTE); /分 WRITE_DS1302(WRITE_DS1302_HOUR,INIT_HOUR); /小時(shí) WRITE_DS1302(WRITE_DS1302_DAY,INIT_DAY); /日期 WRITE_DS1302(WRI

13、TE_DS1302_MONTH,INIT_MONTH); /月份 WRITE_DS1302(WRITE_DS1302_WEEK,INIT_WEEK); /星期 WRITE_DS1302(WRITE_DS1302_YEAR,INIT_YEAR); /年 WRITE_DS1302(DS1302_Trickl_Charge,Hold_DS1302_Charge); /充電方式設(shè)置 WRITE_DS1302(WRITE_DS1302_REINIT_ADDR,DS1302_REINIT_DATA); /用于主控制器重新上電判斷 WRITE_DS1302(WRITE_DS1302_Timing_Hour1

14、,6); WRITE_DS1302(WRITE_DS1302_Timing_Min1,30); WRITE_DS1302(WRITE_DS1302_Timing_Hour2,18); WRITE_DS1302(WRITE_DS1302_Timing_Min2,20); WRITE_DS1302(DS1302_WRITE_PROTECT,DS1302_WRITE_PROTECT_OFF); /允許寫保護(hù) else WRITE_DS1302(DS1302_WRITE_PROTECT,DS1302_WRITE_PROTECT_NO); /禁止寫保護(hù) WRITE_DS1302(DS1302_Trick

15、l_Charge,Hold_DS1302_Charge); /充電方式設(shè)置 WRITE_DS1302(DS1302_WRITE_PROTECT,DS1302_WRITE_PROTECT_OFF); /允許寫保護(hù) #define uchar unsigned char#define uint unsigned int sbit EN=P26;sbit RS=P24;sbit RW=P25;uchar LCD1602_Table="0123456789"/LCD1602顯示標(biāo)尺 /0123456789abcdefuchar code DIS_TIM16 = "2000

16、/00/00 00:00" /時(shí)間日期顯示 2000/00/00 00:00 uchar code DIS_STA16 = "M:Auto WIN:OFF" /系統(tǒng)工作狀態(tài)顯示uchar code DIS_SET_TIM16=" Set the timer: "uchar code DIS_THE_TIM16="O:-:- C:-:-"extern void delayms(uint xms);void WRITE_LCD1602_DAT(uchar date)EN=0;RS=1;P0=date;EN=0;delayms(5

17、);EN=1;void WRITE_LCD1602_COM(uchar date)EN=0;RS=0;P0=date;EN=0;delayms(5);EN=1;void init_1602() unsigned char i;RW=0;WRITE_LCD1602_COM(0x38);WRITE_LCD1602_COM(0x0c);WRITE_LCD1602_COM(0x06);WRITE_LCD1602_COM(0x01);WRITE_LCD1602_COM(0x80);for(i=0;i<16;i+)WRITE_LCD1602_DAT(DIS_TIMi);WRITE_LCD1602_C

18、OM(0x80+0x40);for(i=0;i<16;i+)WRITE_LCD1602_DAT(DIS_STAi);#include<reg52.h>#include"DS1302.H"#include"LCD1602.H"#define uchar unsigned char#define uint unsigned int#define Motor_Step 400#define HIGH 1#define LOW 0#define KEY_NO_NUM 0#define KEY_TIM_SET_NUM 1#define KEY_M

19、ODE_SET_NUM 2#define KEY_ADD_NUM 3#define KEY_MIN_NUM 4#define Auto_MODE 0#define Manual_MODE 1#define Timing_MODE 2unsigned char speed=8; /步進(jìn)電機(jī)的轉(zhuǎn)速uchar Tim_red_tab6=0;/記錄年月日時(shí)分秒和系統(tǒng)狀態(tài)信息uchar Timing_tab22=12,30,15,20;/記錄定時(shí)間uchar Time_num1,Time_num2;uchar time1_num=0;uint time2_num=0;uchar Win_Sta=0; /

20、窗簾狀態(tài) 0打開 1關(guān)閉uchar SET_TIM_FLAG=0;/時(shí)間設(shè)置標(biāo)志位uchar MODE_FLAG=0; /工作模式標(biāo)志位uchar WIN_STA_FLAG=0;/窗簾狀態(tài)標(biāo)志位bit Action_FLAG=0;/窗簾動(dòng)作標(biāo)志位bit Again_flag=0;sbit KEY_TIM_SET=P10;/時(shí)間設(shè)置按鍵sbit KEY_MODE_SET=P11;/定時(shí)時(shí)間設(shè)置按鍵sbit KEY_ADD=P12;/時(shí)間設(shè)置加/手動(dòng)模式開窗簾sbit KEY_MIN=P13;/時(shí)間設(shè)置減/手動(dòng)模式關(guān)窗簾sbit WIR_KEY_TIM_SET=P22;/時(shí)間設(shè)置按鍵sbit WI

21、R_KEY_MODE_SET=P20;/定時(shí)時(shí)間設(shè)置按鍵sbit WIR_KEY_ADD=P23;/時(shí)間設(shè)置加/手動(dòng)模式開窗簾sbit WIR_KEY_MIN=P21;/時(shí)間設(shè)置減/手動(dòng)模式關(guān)窗簾/*sbit MOTOR_IN1=P30;sbit MOTOR_IN2=P31;sbit MOTOR_EN=P32;*/*#define MOTOR_Init MOTOR_IN1=1; MOTOR_IN2=1#define MOTOR_Forward MOTOR_IN1=0; MOTOR_IN2=1#define MOTOR_Reversion MOTOR_IN1=1; MOTOR_IN2=0#def

22、ine MOTOR_ENABLE MOTOR_EN=0#define MOTOR_DISABLE MOTOR_EN=1 */*八拍方式驅(qū)動(dòng),順序?yàn)锳 AB B BC C CD D DA*/unsigned char code clockWise=0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09; unsigned char code clockWise1=0x09,0x01,0x03,0x02,0x06,0x04,0x0c,0x08; sbit Light_IO=P14;void delayms(uint xms);void Time0_init(void);vo

23、id Sys_init(void);void Main_display(void);void keycsan(void);void Control(void);void Timing_display(void);/* 主程序*/void main()Sys_init();while(1)if(MODE_FLAG=Timing_MODE&&SET_TIM_FLAG!=0)Again_flag=1;Timing_display();else Main_display();keycsan();Control();/* 延時(shí)子程序延時(shí)時(shí)間(xms*1)ms*/void delayms(

24、uint xms)uint x,y;for(x=xms;x>0;x-)for(y=110;y>0;y-);/*定時(shí)器0初始化子程序*/void Time0_init(void)TMOD=0X01;TH0=(65536-2000)/256;TL0=(65536-2000)%256;ET0=1;TR0=0;EA=1;/*系統(tǒng)初始化*/void Sys_init(void)/MOTOR_Init;/MOTOR_DISABLE;Time0_init(); /初始化定時(shí)器0INIT_DS1302(); /初始化DS1302init_1602(); /初始化LCD1602WIN_STA_FLA

25、G=READ_DS1302(READ_WIN_STA);if(WIN_STA_FLAG>1) WIN_STA_FLAG=0;MODE_FLAG=READ_DS1302(READ_MODE_STA);if(MODE_FLAG>3)MODE_FLAG=0;Timing_tab00=READ_DS1302(READ_DS1302_Timing_Hour1);if(Timing_tab00>23)Timing_tab00=0;Timing_tab01=READ_DS1302(READ_DS1302_Timing_Min1);if(Timing_tab01>59)Timing_t

26、ab01=0;Timing_tab10=READ_DS1302(READ_DS1302_Timing_Hour2);if(Timing_tab10>23)Timing_tab10=0;Timing_tab11=READ_DS1302(READ_DS1302_Timing_Min2);if(Timing_tab11>59)Timing_tab11=0;WRITE_LCD1602_COM(0x80+0x40+13); /指定顯示字符的地址if(WIN_STA_FLAG=0) WRITE_LCD1602_DAT('O'); WRITE_LCD1602_DAT('F

27、'); WRITE_LCD1602_DAT('F');else WRITE_LCD1602_DAT('O'); WRITE_LCD1602_DAT('N'); WRITE_LCD1602_DAT(' ');WRITE_LCD1602_COM(0x80+0x40+2); /指定顯示字符的地址if(MODE_FLAG=Auto_MODE)WRITE_LCD1602_DAT('A');WRITE_LCD1602_DAT('u');WRITE_LCD1602_DAT('t');WRI

28、TE_LCD1602_DAT('o');WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');else if(MODE_FLAG=Manual_MODE)WRITE_LCD1602_DAT('M');WRITE_LCD1602_DAT('a');WRITE_LCD1602_DAT('n');WRITE_LCD1602_DAT('u');WRITE_LCD1602_DAT('a');WRITE_LCD1602_DAT('l&

29、#39;);elseWRITE_LCD1602_DAT('T');WRITE_LCD1602_DAT('i');WRITE_LCD1602_DAT('m');WRITE_LCD1602_DAT('i');WRITE_LCD1602_DAT('n');WRITE_LCD1602_DAT('g');/*主界面*/void Main_display(void)static uchar Year=0,Month=0,Day=0,Hour=0,Min=0,Sec=0;static uchar i;if(Aga

30、in_flag)Again_flag=0;Year=0;Month=0;Day=0;Hour=0;Min=0;Sec=0;if(SET_TIM_FLAG=0)Tim_red_tab0=READ_DS1302(READ_DS1302_YEAR);Tim_red_tab1=READ_DS1302(READ_DS1302_MONTH);Tim_red_tab2=READ_DS1302(READ_DS1302_DAY);Tim_red_tab3=READ_DS1302(READ_DS1302_HOUR);Tim_red_tab4=READ_DS1302(READ_DS1302_MINUTE);Tim_

31、red_tab5=READ_DS1302(READ_DS1302_SECOND);if(Year!=Tim_red_tab0)Year=Tim_red_tab0;WRITE_LCD1602_COM(0x80+2); /指定顯示字符的地址WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab0/10); /年WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab0%10); /年if(Month!=Tim_red_tab1)Month=Tim_red_tab1;WRITE_LCD1602_COM(0x80+5); /指定顯示字符的地址W

32、RITE_LCD1602_DAT(LCD1602_TableTim_red_tab1/10); /月WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab1%10); /月if(Day!=Tim_red_tab2)Day=Tim_red_tab2;WRITE_LCD1602_COM(0x80+8); /指定顯示字符的地址WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab2/10); /日WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab2%10); /日if(Hour!=Tim_red_tab3)

33、Hour=Tim_red_tab3;WRITE_LCD1602_COM(0x80+11); /指定顯示字符的地址WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab3/10); /時(shí)WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab3%10); /時(shí)if(Min!=Tim_red_tab4)Min=Tim_red_tab4;WRITE_LCD1602_COM(0x80+14); /指定顯示字符的地址WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab4/10); /分WRITE_LCD1602_D

34、AT(LCD1602_TableTim_red_tab4%10); /分WRITE_LCD1602_COM(0x80+13); /指定顯示字符的地址if(Sec=Tim_red_tab5)WRITE_LCD1602_DAT(':'); /秒elseWRITE_LCD1602_DAT(' '); /秒Sec=Tim_red_tab5;elsei+;if(i>10)i=0;WRITE_LCD1602_COM(0x80+13); /指定顯示字符的地址WRITE_LCD1602_DAT(':');WRITE_LCD1602_COM(0x80+2);

35、 /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=1)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTim_red_tab0/10);WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab0%10);WRITE_LCD1602_COM(0x80+5); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=2)WRITE_LCD1602_DAT('

36、; ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTim_red_tab1/10);WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab1%10);WRITE_LCD1602_COM(0x80+8); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=3)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD16

37、02_TableTim_red_tab2/10);WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab2%10);WRITE_LCD1602_COM(0x80+11); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=4)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTim_red_tab3/10);WRITE_LCD1602_DAT(LCD1602_TableTim_red_ta

38、b3%10);WRITE_LCD1602_COM(0x80+14); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=5)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTim_red_tab4/10);WRITE_LCD1602_DAT(LCD1602_TableTim_red_tab4%10);/*定時(shí)界面*/void Timing_display(void)static uchar i;i+;if(i>

39、10)i=0;WRITE_LCD1602_COM(0x80+0x40+2); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=1)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTiming_tab00/10);WRITE_LCD1602_DAT(LCD1602_TableTiming_tab00%10);WRITE_LCD1602_COM(0x80+0x40+5); /指定顯示字符的地址if(i<5&

40、;&SET_TIM_FLAG=2)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTiming_tab01/10);WRITE_LCD1602_DAT(LCD1602_TableTiming_tab01%10);WRITE_LCD1602_COM(0x80+0x40+11); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=3)WRITE_LCD1602_DAT(' ');WRITE_LCD

41、1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTiming_tab10/10);WRITE_LCD1602_DAT(LCD1602_TableTiming_tab10%10);WRITE_LCD1602_COM(0x80+0x40+14); /指定顯示字符的地址if(i<5&&SET_TIM_FLAG=4)WRITE_LCD1602_DAT(' ');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT(LCD1602_TableTimi

42、ng_tab11/10);WRITE_LCD1602_DAT(LCD1602_TableTiming_tab11%10);/*按鍵子程序*/void keycsan(void)static uchar KEY_TIM_SETJ,KEY_MODE_SETJ,KEY_ADDJ,KEY_MINJ,WIR_KEY_TIM_SETJ,WIR_KEY_MODE_SETJ,WIR_KEY_ADDJ,WIR_KEY_MINJ;uchar KEY_NUM=KEY_NO_NUM;uchar i;static uchar TIM_DAT;if(KEY_TIM_SET&KEY_TIM_SETJ)KEY_NUM

43、=KEY_TIM_SET_NUM;KEY_TIM_SETJ=(KEY_TIM_SET);if(KEY_MODE_SET&KEY_MODE_SETJ)KEY_NUM=KEY_MODE_SET_NUM;KEY_MODE_SETJ=(KEY_MODE_SET);if(KEY_ADD&KEY_ADDJ)KEY_NUM=KEY_ADD_NUM;KEY_ADDJ=(KEY_ADD);if(KEY_MIN&KEY_MINJ)KEY_NUM=KEY_MIN_NUM;KEY_MINJ=(KEY_MIN);/*/if(WIR_KEY_TIM_SET&WIR_KEY_TIM_SETJ

44、)KEY_NUM=KEY_TIM_SET_NUM;WIR_KEY_TIM_SETJ=(WIR_KEY_TIM_SET);if(WIR_KEY_MODE_SET&WIR_KEY_MODE_SETJ)KEY_NUM=KEY_MODE_SET_NUM;WIR_KEY_MODE_SETJ=(WIR_KEY_MODE_SET);if(WIR_KEY_ADD&WIR_KEY_ADDJ)KEY_NUM=KEY_ADD_NUM;WIR_KEY_ADDJ=(WIR_KEY_ADD);if(WIR_KEY_MIN&WIR_KEY_MINJ)KEY_NUM=KEY_MIN_NUM;WIR_K

45、EY_MINJ=(WIR_KEY_MIN);switch(KEY_NUM)case KEY_TIM_SET_NUM: /檢測(cè)到時(shí)間設(shè)置按鍵按下 if(MODE_FLAG!=Timing_MODE) SET_TIM_FLAG+; if(SET_TIM_FLAG>5) SET_TIM_FLAG=0; switch(SET_TIM_FLAG) case 1:TIM_DAT=READ_DS1302(READ_DS1302_YEAR); break;case 2:TIM_DAT=READ_DS1302(READ_DS1302_MONTH); break;case 3:TIM_DAT=READ_DS

46、1302(READ_DS1302_DAY); break;case 4:TIM_DAT=READ_DS1302(READ_DS1302_HOUR); break;case 5:TIM_DAT=READ_DS1302(READ_DS1302_MINUTE); break;default: break; else/處于定時(shí)模式 SET_TIM_FLAG+; if(SET_TIM_FLAG>4) SET_TIM_FLAG=0;WRITE_LCD1602_COM(0x80); for(i=0;i<16;i+)WRITE_LCD1602_DAT(DIS_TIMi);WRITE_LCD1602

47、_COM(0x80+0x40);for(i=0;i<2;i+)WRITE_LCD1602_DAT(DIS_STAi);WRITE_LCD1602_DAT('T');WRITE_LCD1602_DAT('i');WRITE_LCD1602_DAT('m');WRITE_LCD1602_DAT('i');WRITE_LCD1602_DAT('n');WRITE_LCD1602_DAT('g');WRITE_LCD1602_COM(0x80+0x40+9); /指定顯示字符的地址WRITE_LCD1

48、602_DAT('W');WRITE_LCD1602_DAT('I');WRITE_LCD1602_DAT('N');WRITE_LCD1602_DAT(':');if(WIN_STA_FLAG)WRITE_LCD1602_DAT('O');WRITE_LCD1602_DAT('N');WRITE_LCD1602_DAT(' ');elseWRITE_LCD1602_DAT('O');WRITE_LCD1602_DAT('F');WRITE_LCD1602_DAT('F'); else if(SET_TIM

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論