精編采用ATC制作的智能時鐘_第1頁
精編采用ATC制作的智能時鐘_第2頁
精編采用ATC制作的智能時鐘_第3頁
精編采用ATC制作的智能時鐘_第4頁
精編采用ATC制作的智能時鐘_第5頁
已閱讀5頁,還剩34頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、(精編)采用ATC制作 的智能時鐘采用AT89C2051制作的智能時鐘一、智能電子鐘的功能1、全日歷計時。2、12/24 小時轉換。3、8 路定時輸出(可關 / 開控制)4、誤差: 15S+1uS5、大、小月,潤年,周,自動追蹤二、調校上電后,電子鐘顯示“1: 00 ”。1、8 路定時時間查詢按下K1鍵依此顯示8路定時時間。星期位顯示:“H”表示:打開當前定時輸出;“ L”表示:關閉當前定時輸出。此時按K2鍵可進行“ H”、“ L”的切換。所有輸出,均由蜂鳴器輸出!2、顯示狀態(tài)的控制按下 K2 鍵可進入以下工作狀態(tài):1) 12 小時 / 日月交替顯示。2) 12 小時固定顯示。3) 24 小時

2、 / 日月交替顯示。4) 24 小時固定顯示。3、校時按下 K2 鍵 3S 后,進入校時菜單。按下 K1 鍵依次進入校時狀態(tài):分、時、天、月、年、微調系數(shù)。此時按 K2鍵,完成+1。當顯示“ d”時,表示要調整微調系數(shù)( 0-99 ),其值越小,時鐘走時越慢。當使用的 6MHz 的晶振偏差大時,應仔細調整微調系數(shù)!當顯示out ”時鍵按即可退出!退出后,按任意鍵即可啟動時鐘。4、設置定時時間按下 K1 鍵 3S 后,進入設置菜單。按下 K1 鍵依次進入 8 路定時調整狀態(tài):時、分。此時按K2鍵,完成+1。當顯示“out ”時,按 鍵,即可退出!三、原理圖和 PCB 圖下一頁 AT89C2051

3、 的智能時鐘單片機源程序以下為 AT89C2051 的智能時鐘的內部程序;2001.5.24 *J;all_clk1_program2000-10-12 *Jfl_250msbit00hfl_500msbitfl_250ms+1set_clk_fbitfl_500ms+1set_al4_fbitset_clk_f+1am_fbitset_al4_f+1fl_3sbitam_f+1al1_fbitfl_3s+1al2_fbitfl_3s+2al3_fbitfl_3s+3al4_fbitfl_3s+4set_overbital4_f+1 ha_fbitset_over+1 ha_overbitha

4、_f+1 fl_ms_fbitha_over+1 fl_s_fbitfl_ms_f+1 key_overbitfl_s_f+1 * Jkey_dataequ08h timersequkey_data+1 t_30msequtimers+1 t_20msequt_30ms+1 t_1sequt_20ms+1 k1_dataequt_1s+1 k2_dataequk1_data+1 stat_workequk2_data+1 stat_ledequstat_work+1 t_1msequstat_led+1 t_20mequt_1ms+1 beepequt_20m al1equbeep+1 al2

5、equbeep+2 al3equbeep+3al4equbeep+4al5equbeep+5al6equbeep+6al7equbeep+7al8equbeep+8ret_timerequal8+1 *Jsecequ23hminequsec+1hhourequmin+1hdayequhour+1hmonequday+1hyearequmon+1hw_adjequyear+1h weekequw_adj+1h *Jal1_hequweek+1hal1_mequal1_h+1hal2_hequal1_m+1hal2_mequal2_h+1hal3_hequal2_m+1h al3_mequal3_

6、h+1hal4_hequal3_m+1hal4_mequal4_h+1hal5_hequal4_m+1hal5_mequal5_h+1hal6_hequal5_m+1hal6_mequal6_h+1hal7_hequal6_m+1hal7_mequal7_h+1hal8_hequal7_m+1hal8_mequal8_h+1hbeep_tequal8_m+1fristequbeep_t+1 *Jled1equfrist+1led2equled1+1led3equled2+1led4equled3+1led5equled4+1sp_dataequled5+1 *Jled_1bitp3.5 led

7、_2bitp3.4 led_3bitp3.3led_4bitp3.2 led_5bitp3.1 beep_fBITP3.7 key_fbitp3.0 *Jt_h_100msequ05dh;100msfor6MHz t_l_100msequ07fh;c6for100ms timer_noequ8d;3c90+30d=3cb0h w_adj_datequ50d key_daequ00000110b * Jblk_ledequ20d dot_ledequ21d f_ledequ22d n_ledequ23d u_ledequ24d t_ledequ25d b_ledequ26d d_ledequ27

8、d oRG0000H;sJMPstartORG0003H;reti;ORG000BH;ajmpt0reti;ORG0013Hreti;ORG001BH;aJMPT1;ORG0023H;RETI;AJMPRS_485;.*Jstart:callclr_ramMOVSP,#sp_data;callint_t0calltimer_intcalltimer_20msSTAR_BI:callclock callal_outcallweek_autoCALLKEY_bord callkey_del callset_clk_al callkey_jmp callreback callled_jmp sjmp

9、star_bi *Jreback: mova,stat_work jzreback_end jbal1_f,ka1 movret_timer,sec setbal1_f sjmpreback_end ka1: mova,ret_timer adda,#05d movb,#60d divab mova,sec cjnea,b,reback_endclral1_f movstat_work,#00d reback_end: retkey_jmp: mova,key_data jzkey_jmp_end movret_timer,sec cjnea,#01d,kk1 mova,stat_work i

10、nca;k1_key cjnea,#9d,kka1 mova,#00d kka1: movstat_work,a sjmpkey_jmp_end kk1: mova,stat_work;k2_key jnzkk2 mova,stat_led inca cjnea,#05d,kka2mova,#00dkka2:movstat_led,a sjmpkey_jmp_end kk2: acallall1 cpla movr0,a key_jmp_end: ret all1: movr0,#al1 mova,stat_work deca adda,r0 movr0,a mova,r0 ret led_j

11、mp:.* J;movstat_work,#01d ;movstat_tw,#01d mova,stat_work jnzled_al1 mova,stat_led acallled_t_d movled1,week sjmpled_jmp_end led_al1: acallall1 movled1,#f_led jnzle_t2movled1,#n_ledle_t2: jbfl_250ms,le_t4 movled1,#blk_ledle_t4: acallal_led led_jmp_end: acallled ret *Jtime_24: mova,houracallbcd_8 mov

12、led2,ajnztim4movled2,#blk_ledtim4:movled3,bjbfl_500ms,tim1mova,badda,#10dmovled3,atim1:acallled_mintime_12_end:ret *Jled_min:mova,minacallbcd_8jbfl_500ms,tim2adda,#10dtim2:movled4,amovled5,bret *Jdate_led: mova,mon acallbcd_8 movled2,a jnzda1movled2,#blk_ledda1:mova,badda,#10dmovled3,amova,dayacallb

13、cd_8movled4,ajnzda2 movled4,#blk_led da2:movled5,b date_led_end: ret.*;D_8=>BCD.*JBCD_8:MOVB,#10DDIVABRET.*JLED:movp1,#0movdptr,#led_asc ;*led1 mova,led1movca,a+dptrmovp1,aclrled_1acalltimer_1msacalltimer_1ms;acalltimer_1ms;acalltimer_1ms;acalltimer_1ms setbled_1.* led_led2:mova,led2 movca,a+dptr

14、 movp1,a clrled_2 acalltimer_1ms setbled_2 ;* led_led3:mova,led3 movca,a+dptrmovp1,aclrled_3 acalltimer_1ms setbled_3led4.* led_led4:mova,led4 movca,a+dptr movp1,a clrled_4acalltimer_1ms setbled_4 ;*led5 led_led5:mova,led5movca,a+dptrmovp1,aclrled_5acalltimer_1mssetbled_5.*Jled_end:movp1,#0ret.*J;ba

15、fhcdegled_asc:db11101110B;0db10001000B;1db11000111B;2db11001101B;3db10101001B;4db01101101B;5db01101111B;6db11001000B;7db11101111B;8db11101101B;9 db11111110B;0.=>10d db10011000B;1. db11010111B;2. db11011101B;3. db10111001B;4. db01111101B;5. db01111111B;6. db11011000B;7. db11111111B;8. db11111101B;

16、9.DB00000000B;BLACK=>20dDB00010000B;dot=>21dDB00100110b;l=>22d dB10101011B;h=>23d DB10101110B;u=>24d DB00100111B;t=>25d dB00101111B;b=>26ddB10001111B;d=>27d;bafhcdeg *J;delay *Jtimer_1ms:movt_1ms,#030hr2_1:djnzt_1ms,r2_1rettimer_20ms:movt_20m,#050dr2_2:callclockcallleddjnzt_2

17、0m,r2_2callweek_autocallal_outret""""""""""""""""""""""""""""""""""""""""""""&qu

18、ot;ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff;ifmon<=2andyear=4Z(0,1,2,3.);gs1=>week=mod(5/4*year+mon_asc(mon)+day-1)/7;else;gs2=>week=mod(5/4*year+mon_asc(mon)+day)/7week_auto:mova,YEARmovb,#05mulab

19、movr4,bmovr5,amovr7,#04callmul_2MOVDPTR,#MON_ASCMOVA,MONdecaMOVCA,A+DPTRADDA,r3 *MOVB,DAYADDA,B movr3,a;r3=gs2MOVA,MON;*jbmon<=2*CJNEA,#02D,WEEK_1SJMPWEEK_2WEEK_1:JCWEEK_2week_3:mova,r3 movb,#07 divab mova,b sjmpweek_4WEEK_2: mova,year movb,#04 divab mova,b jnzweek_3 mova,r3 deca movb,#07;*jbyear

20、=4N*divabmova,b week_4:MOVWEEK,ajnzweek_endmovweek,#07hweek_end:RETMON_ASC:DB6d,2d,2d,5d,0d,3d,5d,1d,4d,6d,2d,4d;2002.5.5;r4r5/r7=r3mul_2:D457:CLRCMOVA,R4SUBBA,R7JCDV50SETBOVRETDV50:MOVR6,#8;求平均值(R4R5/ R7 R3)DV51:MOVA,R5RLCAMOVR5,AMOVA,R4RLCAMOVR4,AMOVF0,CCLRCSUBBA,R7ANLC,/F0JCDV52MOVR4,ADV52:CPLCMO

21、VA,R3RLCAMOVR3,ADJNZR6,DV51MOVA,R4; ;四舍五入ADDA,#0;R4JCDV53SUBBA,R7JCDV54DV53:INCR3DV54:CLROVRET *Jclr_ram:MOVR7,#78h;MOVR0,#0bH;CLRA;CR:INCR0;MOVR0,A; djnzr7,cr;CLRRAM ret.*INT_CTRLint_t0: setbet1MOVTMOD,#00010001b;movw_adj,#w_adj_datsetbea jmpadj_w * al_led: movr0,#al1_h mova,stat_work deca rla adda

22、,r0 movr0,a mova,r0acallbcd_8 movled2,ajnzal_1movled2,#blk_ledal_1:mova,badda,#10dmovled3,aincr0mova,r0acallbcd_8adda,#10dmovled4,amovled5,bal_led_end:ret *Jset_clk_al:jnbset_clk_f,see1callset_clockclrset_clk_fsjmpsee2see1: jnbset_al4_f,see2callset_al4 clrset_al4_f see2: ret *Jprocled_t_d led_t_d: m

23、ovdptr,#led_ord_3 movb,#02h mulab jmpa+dptr led_ord_3:ajmpled_k0_2 ajmpled_k1_2 ajmpled_k2_2 ajmpled_k3_2 ajmpled_k4_2 led_k0_2:;timer_12anddatetoled acalltime_12jnbfl_3s,lk1 acalldate_ledlk1: ajmpled_jmp_5_end led_k1_2:;timer_12toled acalltime_12 ajmpled_jmp_5_end led_k2_2:;timer_24anddatetoled aca

24、lltime_24 jnbfl_3s,lk2acalldate_ledlk2:ajmpled_jmp_5_end led_k3_2:;timer_24toled acalltime_24 ajmpled_jmp_5_end led_k4_2:;sectoled movled1,#blk_led movled2,#blk_led movled3,#dot_led mova,sec acallbcd_8 adda,#10d movled4,amovled5,bled_jmp_5_end:retend.*Jprocset_al4set_al4:movk1_data,#01d movk2_data,#

25、01d clrset_over acallled_al acallkey_bord callsf_key movkey_data,#0 movfrist,#0 set_al41: callclock callweek_auto acallled_al acallkey_bord callkey_del acallkey_aljnbset_over,set_al41clramovk1_data,amovk2_data,a movkey_data,a movfrist,a ret end *Jprockey_alkey_al:mova,key_data jzkey_al_end cjnea,#01

26、d,k2_al inck1_data;(1-9) mova,k1_data cjnea,#19d,key_al_end movk1_data,#01d sjmpkey_al_end k2_al:mova,k1_data cjnea,#018d,ke2setbset_over sjmpkey_al_end ke2: movr0,#al1_h deca adda,r0 movr0,a incr0 acalljj_bit movb,#24d jnzke3 movb,#60d ke3: mova,r0 divab mova,b movr0,a key_al_end: ret end jj_bit: m

27、ova,k1_datamovb,#02ddivabmova,b;(a=1,0)ret.*Jled_out1:movled2,#00hmovled3,#u_ledmovled4,#t_ledmovled5,#blk_ledmovled1,#blk_ledret.*Jled_al:mova,k1_datacjnea,#017d,lo1acallbeep_timersjmpled_al_endlo1:cjnea,#18d,ld1acallled_out1sjmpled_al_endld1: incamovb,#02d divab *Jmovled1,a *Jdecarla movr0,#al1_h

28、adda,r0 movr0,a mova,r0 acallbcd_8 movled2,a jnzld2 movled2,#blk_led ld2: mova,b adda,#10d movled3,a .*incr0 mova,r0acallbcd_8adda,#10d movled4,amovled5,b*flashbit.* jbfl_250ms,led_al_end acalljj_bit jnzled_al_emovled4,#blk_led movled5,#blk_led sjmpled_al_end led_al_e: movled2,#blk_led movled3,#blk_

29、led led_al_end:acallled ret.* procset_clock set_clock: movk1_data,#01d movk2_data,#01d clrset_over callled_cl callkey_bord callsf_key movkey_data,#0 movfrist,#0 set_al41: callclock acallweek_auto callal_out acallled_cl acallkey_bord callkey_del acallkey_cl jnbset_over,set_al41 ;acallkey_bord clra mo

30、vk1_data,a movk2_data,a movkey_data,amovfrist,aretend *Jprockey_clkey_cl:mova,key_data jzkey_al_end cjnea,#01d,k2_al inck1_data;(1-8) mova,k1_data cjnea,#9d,key_al_end movk1_data,#01d sjmpkey_al_end k2_al:mova,k1_data cjnea,#08d,ke2 setbset_over sjmpkey_al_end ke2: deca movdptr,#asc_hmovca,a+dptr mo

31、vb,a.*Jmovr0,#sec mova,k1_data deca adda,r0 movr0,a incr0 mova,r0 divab mova,b movr0,a key_al_end: ret end asc_h: db60d,60d,24d,32d,13d,100d,100d procled_clled_cl: movdptr,#led_ord_3 mova,k1_datadeca movb,#02hmulabjmpa+dptr led_ord_3:ajmpled_k0_2 ajmpled_k1_2 ajmpled_k2_2 ajmpled_k3_2 ajmpled_k4_2 a

32、jmpled_k5_2 ajmpled_k6_2 ajmpled_k7_2 led_k0_2:;ledsec movled2,#blk_led movled3,#dot_led mova,sec acallbcd_8 adda,#10d movled4,a movled5,b jbfl_250ms,lk1 movled4,#blk_ledmovled5,#blk_ledlk1: ajmpled_jmp_5_end led_k1_2:;ledmin,hour acallled_hour jbfl_250ms,lk2 movled4,#blk_led movled5,#blk_ledlk2: aj

33、mpled_jmp_5_end led_k2_2:;ledmin,hour acallled_hour jbfl_250ms,lk3 movled2,#blk_led movled3,#blk_ledlk3:ajmpled_jmp_5_end led_k3_2:;ledday,mon acallled_mon jbfl_250ms,lk4 movled4,#blk_led movled5,#blk_ledlk4: ajmpled_jmp_5_end led_k4_2:;ledday,mon acallled_mon jbfl_250ms,lk5 movled2,#blk_led movled3

34、,#blk_led lk5: ajmpled_jmp_5_end led_k5_2:;ledyear movled2,#2d movled3,#0d mova,year acallbcd_8 movled4,a movled5,b jbfl_250ms,lk6 movled4,#blk_led movled5,#blk_led lk6: ajmpled_jmp_5_end led_k6_2:;ledw_adj movled2,#d_led movled3,#blk_led mova,w_adj acallbcd_8 movled4,a movled5,b jbfl_250ms,lk7 movl

35、ed4,#blk_led movled5,#blk_led lk7: ajmpled_jmp_5_end led_k7_2:;ledout acallled_out1 led_jmp_5_end: movled1,week acallled ret end led_hour: mova,hour acallbcd_8 movled2,ajnzlj1 movled2,#blk_led lj1: mova,b adda,#10d movled3,a *Jmova,minacallbcd_8adda,#10dmovled4,amovled5,bretled_mon:mova,monjnzlj5inc

36、monmova,monlj5:acallbcd_8movled2,ajnzlj2movled2,#blk_ledlj2:movled3,b *Jmova,dayjnzlj4incdaymova,daylj4:acallbcd_8movled4,ajnzlj3movled4,#blk_ledlj3:movled5,bret *Jal_out:jbha_over,al_out_endmovr7,#8d movr1,#al8_m al_ch_1:movr0,#minmovr6,#02d;minhoural_l:mova,r0movb,r1cjnea,b,al_chincr0decr1djnzr6,a

37、l_l.*Jmova,r7decamovr0,#al1adda,r0movr0,amova,r0movc,acc.0cplcanlc,fl_250mscplcmovbeep_f,cacallbeep_outal_ch: clrcmova,r1subba,r6movr1,adjnzr7,al_ch_1al_out_end:retbeep_out:jbha_f,ba1movbeep,sec setbha_f ba1:mova,beepadda,beep_tmovb,#60ddivabmova,sec cjnea,b,beep_out_end setbbeep_f setbha_over clrha

38、_f beep_out_end:ret timer_int:MOVT_1S,#TIMER_no movbeep_t,#15d movyear,#01d movmon,#011d movday,#06d movhour,#13d movmin,#00d movsec,#00d movr7,#16 movdptr,#al_asc movr0,#al1_h al_read: clra movca,a+dptr movr0,a incr0 incdptr djnzr7,al_read ret.* beep_timer: movled1,#blk_led movled2,#b_led movled3,#

39、blk_led mova,beep_t acallbcd_8 movled4,a movled5,b jbfl_250ms,ft1 movled4,#blk_led movled5,#blk_led ft1: ret time_12: movdptr,#asc_12 mova,hour rla movca,a+dptr movled2,a jnziu2 movled2,#blk_lediu2: incdptrmova,hourrlamovca,a+dptrjbfl_500ms,iu1adda,#10diu1:movled3,a;*mintoledacallled_mintime_24_end:

40、retasc_12:db11d,2d,21d,1d,21d,2d,21d,3d,21d,4d,21d,5d,21d,6d,21d,7ddb21d,8d,21d,9d,11d,0d,11d,1ddb1d,2d,0d,1d,0d,2d,0d,3d,0d,4d,0d,5d,0d,6d,0d,7d,0d,8d,0d,9ddb1d,0,1d,1dclock: *Jmova,seccjnea,#60d,clock_end;!movsec,#00h incmin *Jclrha_over;2001.5.6 mova,min cjnea,#60d,clock_end movmin,#00h inchour m

41、ova,hour cjnea,#24d,clock_end movhour,#00h mova,mon xrla,#02d jnzmm_1 movdptr,#year_d mova,year movca,a+dptr sjmpmm_2 mm_1: mova,mon deca movdptr,#mou_12movca,a+dptrmm_2: movb,a incbincday;*day+1mova,day cjnea,b,clck_endsjmpclck1 clck_end: jcclock_end clck1: movday,#01hincmon mova,mon cjnea,#13d,clo

42、ck_end movmon,#01d incyear mova,year cjnea,#100d,clock_end movyear,#00d clock_end: callfl_out ret mou_12:db31d,28d,31d,30d,31d,30d db31d,31d,30d,31d,30d,31d year_d:db29d,28d,28d,28d,29d,28d,28d,28d,29d,28ddb28d,28d,29d,28d,28d,28d,29d,28d,28d,28ddb29d,28d,28d,28d,29d,28d,28d,28d,29d,28ddb28d,28d,29d

43、,28d,28d,28d,29d,28d,28d,28d db'lijie2000.5.15' *Jt1:pushapushpswpushb clrfl_ms_f djnzt_1s,t1_end clrfl_s_f incsec calladj_w * t1_end: popb poppsw popa reti adj_w: clrtr1 mova,#T_L_100ms adda,w_adj;*have5order movtl1,a mova,#T_H_100ms addca,#00hmovth1,a movt_1s,#timer_no setbtr1 ret fl_out: jbfl_ms_f,fl_out_end setbfl_ms_f mova,t_1s movb,#02d divab mova,bjnzto_d1 cplfl_250ms to_d1: mova,t_1s movb,#04d divab mova,b jnzto_d2 cplfl_500ms to_d2: f

溫馨提示

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

評論

0/150

提交評論