MICROCONTROLLERCPURAMROM/I/OMCS-511-11518CPU32I/OROMRAM64K3l6/521-2MCS-5lCPU21-2MCS-51MCS-51CPU(SFR)ALUPSW1-3D7D6D5D4D3D2D1D0CYACF0RS1RS0OVP1-3PSW3CYCY=1CY=0ACD3D4AC=1F0RS1RS00~31-2RS1RS000000-0701108-0F10210-1711318-1FOV-128~+127OV=1OV=02550OV=1OV=0PAlP=1P=0DPTRPC1MCS-51MCS-51XTAL1XTAL2XTAL2XTAL1Vss(a)(b)l-42MCS-51MCS-5146(S)1-512MCS-51l-424ROMRAMMCS-510000-FFFFH1-5MCS-51RAM64KBROMMCS-51ROMRAMROMRAM51-8MCS-5162EPROM117TT82T2RL9ORG8000H010000B;C#includereg52.h//SCON=0X10;//MOVSCON#00MOVSBUF#88HJNBTI,$CLRTIEND#includestdio.h//main(){SBUF=0X88;//while(!TI);//TI=0;}10××−1232fosc2561/(322SMOD×)]1TH(256[12f322oscSMOD−××)]L2RCAP,H2RCAP(65536[162fosc−××111213MCS-51I/O1-29MCS-511-32l-33141-361-386264RAMMCS-51MOVAR0A(R0)MOVA4FHA4(4FH)MOVA#6FHA6FHMOVA@R1A((R1))SJMPrelPC(PC)+2+relMOVCA@ADPTRA4((A)(DPTR))SETBEAEA=1MCS-5115MCS-51?166400=÷1617KEIL51PLMC2.22.32.4182.52.6MCS-51A/DD/AICC74LS57374LS373P14ORG8000HCLRP3.3MOVP1#00HP1MOVP1#80H80SETBP3.3CLRP3.3ENDC#includereg52.h//#includestdio.h//19sbitCLK=P3^3;main(){CLK=0;//P1=0X00;//P1P1=0X80;//80CLK=1;//CLK=0;//}4-20000H~1FFFHCORG0000HMOVDPTR#0000HMOVA#80HMOVX@DPTRAENDC#includereg52.h#includestdio.h#includeabsacc.h#defineour_portXBYTE[0x0000]main(){our_port=0x80;}74HC138A15A14A1364K880000H~1FFFH20PLD4-3subdesignencoder(A15,A14,A13,A12,A11,A10,A9,A8:INPUT;A7,A6,A5,A4,A3,A2,A1,A0,WR:INPUT;ENABLE:OUTPUT;)BEGINENABLE=A15&A14&A13&A12&A11&A10&A9&A8&A7&A6&A5&A4&A3&A2&A1&A0&!WR;END;80514-44-4CORG0000HMOVSCON#00000000BMOVSBUF#88HENDC#includereg52.h//#includestdio.h//main(){SCON=0X00;//SBUF=0X88;//}4-5C21ORG0000HSETBP1.0CLRP1.0SETBP1.0MOVSCON#00010000B0JNBRI,$MOVASBUFCLRRIENDC#includereg52.h//#includestdio.h//sbitload=P1^0;main(){unsignedcharx;load=1;//load=0;//load=1;//SCON=0X10;//0while(!RI);//x=SBUF;//RI=0//}ORG0000HMOVSCON#00HCLRTIMOVSBUF#01H8JNBTI$22CLRTIMOVSBUF,#9FH1JNBTI$CLRTIENDC#includereg52.h//#includestdio.h//main(){SCON=0X00;//TI=0;//SBUF=0X01;//8while(!TI);//TI=0;//SBUF=0X9F;//1while(!TI);//TI=0;//}4-64-7874LS37378ULN2803ULN28038500mA880mAULN280380mAS0S17F80H7F90H12.5mSC#includeat89x52.h#includestdio.h#includeabsacc.h23#defineSEGMENTXBYTE[0x8000]//#defineBIT_LEDXBYTE[0x8001]//#definefosc11.0592//#definetime02500//2500uSunsignedchardatadisplay_bit,display_buffer[8];unsignedchardatatime0_h,time0_l;unsignedintidatatime0_times;unsignedcharget_code(unsignedchari);voiddisplay(void);main(){BIT_LED=0;TMOD=0x21;///01time0_times=65536-time0*fosc/12;time0_h=(time0_times/256);time0_l=(time0_times%256);TH0=time0_h;TL0=time0_l;//88TR0=1;//0EA=ET0=1;//display_bit=0x01;//display_buffer[7]=8;display_buffer[6]=7;display_buffer[5]=6;display_buffer[4]=5;display_buffer[3]=4;display_buffer[2]=3;display_buffer[1]=2;display_buffer[0]=1;while(1);}voidtime0_int(void)interrupt1//{TH0=time0_h;TL0=time0_l;24display();//40m}unsignedcharget_code(unsignedchari){unsignedcharp;switch(i){case0:p=0x3F;break;/*0*/case1:p=0x06;break;/*1*/case2:p=0x5B;break;/*2*/case3:p=0x4F;break;/*3*/case4:p=0x66;break;/*4*/case5:p=0x6D;break;/*5*/case6:p=0x7D;break;/*6*/case7:p=0x07;break;/*7*/case8:p=0x7F;break;/*8*/case9:p=0x67;break;/*9*/case10:p=0x77;break;/*A*/case11:p=0x7C;break;/*B*/case12:p=0x39;break;/*C*/case13:p=0x5E;break;/*D*/case14:p=0x79;break;/*E*/case15:p=0x71;break;/*F*/default:break;}return(p);}voiddisplay(void){unsignedchari;switch(display_bit){case1:i=0;break;case2:i=1;break;case4:i=2;break;case8:i=3;break;case16:i=4;break;case32:i=5;break;25case64:i=6;break;case128:i=7;break;default:break;}{BIT_LED=0;//SEGMENT=get_code(display_buffer[i]);//BIT_LED=display_bit;//if(display_bit0x64){display_bit=display_bit*2;}elsedisplay_bit=0x01;}}262728DS1302DS130231RAMDS1302DS13024-194-20DS13024-21DS1302I/ODS13024-21DS1302#includereg52.h#includeintrins.hsbitSCL_DS1302=P1^0;//sbitIO_DS1302=P1^1;//sbitRST_DS1302=P1^2;//unsignedchardatadisplay_buffer[8];unsignedcharbdatadata_ds1302;sbitbit_data0=data_ds1302^0;sbitbit_data7=data_ds1302^7;unsignedcharbdatax;sbitx0=x^0;sbitx7=x^7;voidopen_write_bit();voidinitial_ds1302();unsignedcharread_ds1302(charcommand);voidopen_write_bit();voidclose_write_bit();voidread_time();voidset_time();29main(){initial_ds1302();//,read_time();//,display_buffer[0]=0X00;display_buffer[1]=0X08;display_buffer[4]=0X01;display_buffer[5]=0X00;display_buffer[6]=0X05;display_buffer[7]=0X08;//081058set_time();//DS1302while(1);}voidclose_write_bit(){chari;SCL_DS1302=0;_nop_();RST_DS1302=1;_nop_();_nop_();data_ds1302=0x8e;//writecontrolredisterfor(i=1;i=8;i++){SCL_DS1302=0;IO_DS1302=bit_data0;_nop_();SCL_DS1302=1;data_ds1302=data_ds13021;}data_ds1302=0x80;//closewriteprotectbitIO_DS1302=0;for(i=1;i=8;i++){SCL_DS1302=0;IO_DS1302=bit_data0;_nop_();SCL_DS1302=1;data_ds1302=data_ds13021;}}voidopen_write_bit()30{chari;SCL_DS1302=0;_nop_();RST_DS1302=1;_nop_();_nop_();data_ds1302=0x8e;//writecontrolredisterfor(i=1;i=8;i++){SCL_DS1302=0;IO_DS1302=bit_data0;_nop_();SCL_DS1302=1;data_ds1302=data_ds13021;}data_ds1302=0x00;//openwriteprotectbitIO_DS1302=0;for(i=1;i=8;i++){