资源描述:
《单片机电子钟设计代码 (singlechip electronic clock design code )》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、单片机电子钟设计代码(2)(Singlechipelectronicclockdesigncode(2))Giveyoua,Idotheelectronicclockprocedures,reference,timeisadjustable,thereisakeyscaninit*************************************;FileName:timer_controlableChiptype:ATMELMEGA8Programetype:ApplicationClockfrequency:8MHZMemorymodel:smallExternal,S
2、RAM,size:0Data,stack,size:256*************************************;.include"m8def.inc"".deftime_counter=r16;timecountunit.defkey_stime_counter=r17.defkey_input=r18;keyinputunit.defposit=r19;LEDdisplaycharactershiftpointer.deftemp=r20;temporaryregister.deftemp1=r21.defkey_press=r22.defkey_retu
3、rn=r23.defclock_state=r24;thestateofthestatemachine.defkey_state=r25.defkey_temp=r7.defcount=r8.deftemp2=r1.defset_on=r2;timeblinkmark.defreturn_time=r3.defpoint_on=r4;secondblinkingsign.deftime_1s_ok=r5;1stomark.defkey_stime_ok=r6;10mstomark.equkey_no=0;nobuttonsign.equkey_k1=1;buttonK1logo.
4、equkey_k2=2;buttonK2logo.equkey_mask=0b11000000;buttonidentificationmark.equkey_state_0=0;status0.equkey_state_1=1;status1.equkey_state_2=2;status2.org0x0000Rjmpmain.org0x0003;T2comparesmatchinginterruptvectoraddressesRjmptimer2_com_isr.org0x0020-----------------------------------------------
5、--------------------------------------------------------------------------------------------;Mainprogram-------------------------------------------------------------------------------------------------------------------------------------------;Main:Initializethestack;--**--;LDI,temp,0x5fOut,S
6、PL,tempLDI,temp,0x02Out,SPH,temp*--PB,PD--*initialization;LDI,temp,0x00Out,portb,temp;PBportoutputtodosectioncodecontrolLDI,temp,0xffOut,ddrb,tempOut,portd,tempLDI,temp,0x3f;PD0~5outputbitcontrolOut,ddrd,temp;PD6~7fortimeadjustmentinput*--T2initialization--*;LDI,temp,0x0DOut,tccr2,temp;intern
7、alclock,128frequencydivision(8M/128=62.5KHZ),CTCmodeLDI,temp,0x7cOut,OCR2,temp;ocr2=0x7c(124),(124+1)/62.5khz=2msidestemp,0x80outtimsk定时器2比较匹配中断使能,temp.;*--时钟初始化为:23:58:55--*.idesxl,low(time_buff)idesxi,high(time_buff)idestemp,55stx+s;秒:55ide