CCC80C51CCC1CKeil80C51KeilCµVisionCC1-189S5280C518KFLASHROM,ISP89S52P18P3.2~P3.44P111C1-1P1.0LED/**************************************************************************************************/1-1LED#include“reg51.h”sbitP1_0=P1^0;voidmain(){P1_1=0;}P1.0LEDC14CREG51.hP1CP180C51P1reg51.h/*-------------------------------------------------------------------------REG51.HHeaderfileforgeneric80C51and80C31microcontroller.Copyright(c)1988-2001KeilElektronikGmbHandKeilSoftware,Inc.Allrightsreserved.--------------------------------------------------------------------------*//*BYTERegister*/sfrP0=0x80;sfrP1=0x90;sfrP2=0xA0;sfrP3=0xB0;sfrPSW=0xD0;sfrACC=0xE0;sfrB=0xF0;sfrSP=0x81;sfrDPL=0x82;sfrDPH=0x83;sfrPCON=0x87;sfrTCON=0x88;sfrTMOD=0x89;sfrTL0=0x8A;sfrTL1=0x8B;sfrTH0=0x8C;sfrTH1=0x8D;sfrIE=0xA8;sfrIP=0xB8;sfrSCON=0x98;sfrSBUF=0x99;/*BITRegister*//*PSW*/sbitCY=0xD7;sbitAC=0xD6;sbitF0=0xD5;sbitRS1=0xD4;sbitRS0=0xD3;sbitOV=0xD2;sbitP=0xD0;/*TCON*/sbitTF1=0x8F;sbitTR1=0x8E;sbitTF0=0x8D;sbitTR0=0x8C;sbitIE1=0x8B;sbitIT1=0x8A;sbitIE0=0x89;sbitIT0=0x88;/*IE*/sbitEA=0xAF;sbitES=0xAC;sbitET1=0xAB;sbitEX1=0xAA;sbitET0=0xA9;sbitEX0=0xA8;/*IP*/sbitPS=0xBC;sbitPT1=0xBB;sbitPX1=0xBA;sbitPT0=0xB9;sbitPX0=0xB8;/*P3*/sbitRD=0xB7;sbitWR=0xB6;sbitT1=0xB5;sbitT0=0xB4;sbitINT1=0xB3;sbitINT0=0xB2;sbitTXD=0xB1;sbitRXD=0xB0;/*SCON*/sbitSM0=0x9F;sbitSM1=0x9E;sbitSM2=0x9D;sbitREN=0x9C;sbitTB8=0x9B;sbitRB8=0x9A;sbitTI=0x99;sbitRI=0x98;80C51sfrP1=0x90;P10x90P10x900x90C90HsfrsfrCKeil80C51SFRsfrt=2P1_0P1.0CP1.0CP1.0CP1_0P1_0P1.0CKeilCsbitsbitsbitsbitSFR^sbitSFR^PSWOVsbitOV=0xd210xd2OVsbitOV=PSW^22PSWsfrsbitOV=0xD0^230xD0PSWsfrP1_0=P1^0;P1_0P1.0P103mainC{}C1-2P1.0LED/**************************************************************************************************/#includereg51.h#defineucharunsignedchar#defineuintunsignedintsbitP10=P1^0;/*Delay*/voidmDelay(unsignedintDelay){unsignedinti;for(;Delay0;Delay--){for(i=0;i124;i++){;}}}voidmain(){for(;;){P10=!P10;//P1.0mDelay(1000);}}mainP1_0=!P1_0;P1_0C+-CP1_0P1_0P1_0P1_0P1.0LEDP1.0LEDP1.0P1.0P1.0mainfor(;;){}mDelay(1000);1smDelay(1000)KeilCvoidmDelay(…)mDelaymDelay1000mDelay(1000)mDelaymain()mDelay1000100010001000mDelay12KeilKeilKeilEvalµVisonFileÆNew…1-2FileÆSaveC.Cexam2.cKeilCKeilProjectProject-NewProject…exam21-2CPUKeilCPUAtmel89S52ATMEL+89S52Target1++SourceGroup1SourceGroup11-3AddfiletoGroup”SourceGroup1exam2.c1-4CloseSourceGroup1exam3.c13ProjectTarget1Project-Optionfortarget‘target1’8Target1-21-31-5XtalCPUMemoryModelRAMSmallRAMCompact256RAMLargetRAMCodeModelROMSmall2KCompact2K64KLarget64KOperatingKeilRtxtinyRtxfullNoneNone1-51-4OutPut1-6CreatHexfile,intelHEX.HEXC51A51BL51Listing*.lst*.m51CCompileListingAssambleCodeCCListCCC51KeilC51CodeOptimization1.7LevelC5198Emphasis1-6DebugKeilUseSimulator14CP1LEDexam3.cexam3exam3.cTargetXtal24.012.0DebugDialogDLLDebugDebugDialogDLLParmeter:-pAT52-dledkey1-81-3P1LED/**************************************************;;**************************************************/#includereg51.h#includeintrins.h#defineucharunsignedchar#defineuintunsignedint/*Delay*/voidmDelay(unsignedintDelay){unsignedinti;for(;Delay0;Delay--){for(i=0;i124;i++){;}}}voidmain(){unsignedcharOutData=0xfe;for(;;){1-8DebugP1=OutData;OutData=_crol_(OutData,1);//mDelay(1000);/*1000*/}}Project-BuildtargetRebuildAlltargetfilesTranslate….1-9Build1-10exam3.hexcode=63RAMdata=9RAMxdata=0Keil15Ctrl+F5Debug-Start/StopDebugSessionKeilCPUCPUDebug1-11Debug1PeripheralsLEDK1-91-111-101-12STEPF11STEPOVERF10CF11F11mDelay(1000);F11mDelayF11mDelaymDelayF10F11mainmDelay(1000)KeilmDelayCsecF10mDelay(1000)secsecF10mDelay(1000)sec1-130.000404001.014426001.014022s1241s1231s1241-125116C1CCCmain()CC3_crol_…23mDelay…KeilCCKeilC10021voidmDelay(unsignedintDelayTime)2{}{}1.2unsignedcharjvoidmDelay(){}3Cmainmain()1.21-13sec4mDelaymdelayC5C6C7/*…..*/C/**/*/*/C*/KeilCC++//P1_0=!P1_0;//P1.0KeilCFranklinCPCTC2KeilCC2189S52P18LED0LEDP3.2P3.3P3.4P3.5K1~K4K1K2K3K42-1#includereg51.h#includeintrins.h#defineucharunsignedcharvoidmDelay(unsignedintDelayTime){unsignedintj=0;for(;DelayTime0;DelayTime--){for(j=0;j125;j++){;}}}ucharKey(){ucharKeyV;uchartmp;P3=P3|0x3c;//KeyV=P3;if((KeyV|0xc3)==0xff)//return(0);mDelay(10);//KeyV=P3;if((KeyV|0xc3)==0xff)return(0);else{for(;;){tmp=P3;if((tmp|0xc3)==0xff)break;}return(KeyV);}}voidmain(){unsignedcharOutData=0xfe;bitUpDown=0;bitStart=0;ucharKValue;for(;;){KValue=Key();switch(KValue){case0xfb://P3.2=0,Start{Start=1;break;}case0xf7://P3.3=0,Stop{Start=0;break;}case0xef://P3.4=0Up{UpDown=1;break;}case0xdf://P3.5=0Down{UpDown=0;break;}}if(Start){if(UpDown)OutData=_crol_(OutData,1);elseOutData=_cror_(OutData,1);P1=OutData;}elseP1=0xff;//mDelay(1000);}}C19exam21.cexam21CPUAT89S52Debug-d