µÚ10Õ ´®Ðнӿڼ¼Êõ
1. 8051ÓÐÒ»¸öȫ˫¹¤µÄ´®Ðпڣ¬ÏÂÁй¦ÄÜÖиô®Ðпڲ»ÄÜÍê³ÉµÄÊÇ£¨ D £©¡£ £¨A£©ÍøÂçͨÐÅ£»£¨B£©Òì²½´®ÐÐͨÐÅ£»£¨C£©×÷Ϊͬ²½ÒÆÎ»¼Ä´æÆ÷£» £¨D£©Î»µØÖ·¼Ä´æÆ÷¡£ 2£®ÅжÏÏÂÁÐ˵·¨ÊÇ·ñÕýÈ·£º ´ð£º£¨A£©´®ÐпÚͨѶµÄµÚ9Êý¾ÝλµÄ¹¦ÄÜ¿ÉÓÉÓû§¶¨Òå¡££¨¶Ô£©
£¨B£©·¢ËÍÊý¾ÝµÄµÚ9Êý¾ÝλµÄÄÚÈÝÔÚSCON¼Ä´æÆ÷µÄTB8λÖÐÔ¤ÏÈ×¼±¸ºÃµÄ¡££¨¶Ô£© £¨C£©´®ÐÐͨѶ֡·¢ËÍʱ£¬Ö¸Áî°ÑTB8λµÄ״̬ËÍÈë·¢ËÍSBUFÖС££¨´í£© £¨D£©´®ÐÐͨѶ½ÓÊÕµ½µÄµÚ9λÊý¾ÝËÍSCON¼Ä´æÆ÷µÄRB8Öб£´æ¡££¨¶Ô£© £¨E£©´®Ðпڷ½Ê½1µÄ²¨ÌØÂÊÊǿɱäµÄ£¬Í¨¹ý¶¨Ê±Æ÷/¼ÆÊýÆ÷T1µÄÒç³öÂÊÉ趨¡££¨¶Ô£© 3£®´®ÐпÚÓм¸ÖÖ¹¤×÷·½Ê½£¿Óм¸ÖÖÖ¡¸ñʽ£¿¸÷ÖÖ¹¤×÷·½Ê½µÄ²¨ÌØÂÊÈçºÎÈ·¶¨£¿
´ð£º´®ÐпÚÓÐ3ÖÖ¹¤×÷·½Ê½£º·½Ê½0¡¢·½Ê½1¡¢·½Ê½2¡¢·½Ê½3£»ÓÐ3ÖÖÖ¡¸ñʽ£º·½Ê½0Ϊ8λÊý¾Ý£¬·½Ê½1Ϊ8λÊý¾Ý¡¢Æðʼλ¡¢ÖÕֹ룬·½Ê½2ºÍ3¾ßÓÐÏàͬµÄÖ¡¸ñʽ£¬Îª9λÊý¾Ý¡¢Æðʼλ¡¢ÖÕֹλ£»·½Ê½0µÄ·¢ËͺͽÓÊÕ¶¼ÒÔfosc/12Ϊ¹Ì¶¨²¨ÌØÂÊ£¬·½Ê½2µÄ²¨ÌØÂÊ=2^SMOD/64¡Áfosc£¬·½Ê½1ºÍ·½Ê½3µÄ²¨ÌØÂÊ=2^SMOD/32¡Á¶¨Ê±Æ÷T1µÄÒç³öÂÊ£¬T1µÄÒç³öÂÊ=£¨256-X£©*12/fosc
4£®ÎªÊ²Ã´¶¨Ê±Æ÷/¼ÆÊýÆ÷T1ÓÃ×ö´®Ðпڲ¨ÌØÂÊ·¢ÉúÆ÷ʱ£¬²ÉÓ÷½Ê½2£¿ÈôÒÑ֪ʱÖÓÆµÂÊ¡¢Í¨Ñ¶²¨ÌØÂÊ£¬ÈçºÎ¼ÆËãÆä³õÖµ£¿
´ð£ºÒòΪ¶¨Ê±Æ÷/¼ÆÊýÆ÷ÔÚ·½Ê½2Ï£¬³õÖµ¿ÉÒÔ×Ô¶¯ÖØ×°£¬ÕâÑùÔÚ×ö´®¿Ú²¨ÌØÂÊ·¢ÉúÆ÷ÉèÖÃʱ£¬¾Í±ÜÃâÁË֨װ²ÎÊýµÄ²Ù×÷¡£
¶¨Ê±Æ÷1ÔÚ¹¤×÷·½Ê½2ʱµÄ³õʼֵΪ X=256-[£¨SMOD+1£©/£¨384*²¨ÌØÂÊ£©]*fosc 5£®ÎªÊ²Ã´MCS-51´®Ðпڵķ½Ê½0Ö¡¸ñʽûÓÐÆðʼ루0£©ºÍֹͣ루1£©?
´ð£ºÒòΪ´®Ðпڵķ½Ê½0ÊÇͬ²½ÒÆÎ»¼Ä´æÆ÷·½Ê½£¬²»ÊÇÓÃÓÚÒì²½´®ÐÐͨѶµÄ£¬ËùÒÔÊÕ·¢Ë«·½²»ÐèҪȷ¶¨Êý¾ÝÖ¡µÄÆðʼºÍÖÕÖ¹£¬ËùÒÔûÓÐÆðʼ루0£©ºÍֹͣ루1£©¡£ 6.³£Óò¨ÌØÂʼ°Æä²ÎÊýÑ¡Ôñ Fosc(MHZ) SMOD TH1³õÖµ 19200 11.0592 1 FDH 9600 0 FDH 4800 0 FAH 2400 0 F4H 1200 0 E8H
ÀýÌâ7.µ¥Æ¬»úÖ÷Ƶ6MHz£¬²¨ÌØÂÊ4800bps Òª°Ñ·¢ËͶ˵Ä30H¡ª3FH·¢Ë͵½½ÓÊն˵Ä40H¡ª4FH¡£Ð´³ö³õʼ»¯³ÌÐò£¬½Ó·¢³ÌÐò£¬²¢Ð´³öÉè¼Æ¹ý³Ì£º ·½Ê½1,3 X=256-Fosc*(SMOD+1)/(384*²¨ÌØÂÊ)
=256-6M*1/(384*4800)=251.6=FCH
·¢ËͶˣº
ORG 0000H ÉèÖô®¿Ú¹¤×÷·½Ê½3 MOV SBUF,A AJMP MAIN_A MOV PCON,#00H SJMP $ ORG 0023H ²¨ÌØÂʲ»¼Ó±¶ --------------- AJMP SEND MOV R0£¬#30H ORG 0200H ORG 0100H MOV R2,#10H SEND:CLR TI MAIN_A:MOV SETB EA DJNZ R2£¬SEND1
TMOD,#20H SETB ES SJMP FH
MOV TH1£¬#0FCH MOV A,@R0 SEND1£ºINC R0 MOV TL1£¬#0FCH MOV C,P MOV A,@R0 SETB TR1 MOV TB8£¬C MOV C,P MOV SCON,#0C0H ÆæÅ¼Ð£Ñé MOV TB8£¬C
MOV SBUF,A FH: RETI --------------- END
½ÓÊܶˣº
ORG 0000H AJMP MAIN_B --------------- ORG 0023H AJMP RECV --------------- ORG 0100H MAIN_B:MOV TMOD,#20H MOV TH1£¬#0FCH MOV TL1£¬#0FCH SETB TR1
MOV SCON,#0C0H MOV PCON,#00H MOV R0£¬#40H MOV R2,#10H SETB REN SETB EA SETB ES SJMP $ --------------- ORG 0200H RECV:CLR RI MOV A,SBUF JNB PSW.0,PZ JNB RB8,ERR SJMP RIGHT PZ:JB RB8,ERR RIGHT:MOV@R0,A INC R0 DJNZ R2,FH CLR F0 FH: RETI --------------- ERR:CLR REN CLR ES CLR EA SETB F0 RETI
--------------- END
---------------------------------------------------------------------------------------------------------------------- µÚ9ÕÂD/Aת»»ºÍA/Dת»» ÀýÌâ1£®ÓÃDAC0832×÷Ϊ²¨Ðη¢ÉúÆ÷£¬Çë±àÖÆ³öÁ¬ÐøÌÝÐεijÌÐò£¬Éè0832µÄ¿ÚµØÖ·ÎªC004H.
ORG O100H MAIN:
MOV DPTR , #0C004 CLR A
LOOP1:MOVX,@DPTR,A LCALL DELAY INC A
CJNE A, #OFFH,LOOP1; MOV R2,#00H
LOOP2:MOVX,@DPTR,A LCALL DELAY INC R2
CJNE R2, #OFFH,LOOP2; LOOP3:MOVX,@DPTR,A LCALL DELAY DEC A
CJNE A,#00H,LOOP3; MOV R2,#00H
LOOP4:MOVX,@DPTR,A LCALL DELAY INC R2
CJNE R2, #OFFH, LOOP4;
SJMP LOOP1
DELAY:MOV R3, #XX1 DEL1: MOV R4, #XX2 DEL2: MOV R5, #XX3 DEL3: DJNZ R5, DEL3 DJNZ R4, DEL2 DJNZ R3, DEL1 RET END
----------------------------------------------------------------------------------------------------------------------
ÀýÌâ2£®ÈôÒªÇóÉè¼ÆÒ»Êý¾Ý²É¼¯ÏµÍ³£¬ÊäÈëΪ0-5V,ÓÉIN1ÊäÈ룬ʹÓÃAD0809о
Ƭÿ¸ô20ms²É¼¯Ò»´Î£¬¹²²É¼¯16´Î£¬²¢½«×ª»»ºóµÄÊý¾Ý´æÈë30H¿ªÊ¼µÄµ¥ÔªÖС£
£¨1£© Éè¼ÆÓйصç·ͼ£¬º¬A/D,ÒëÂë¼°Ïà¹Øµç·£¬½ÓÏßÇå³þ£¬Ð´Ã÷ÐźÅÃû³Æ£» £¨2£© ±àÖÆÓйسÌÐò£¬ÉèADÆðʼ¿ÚµØÖ·ÎªÑ§ºÅ×îºó2λX8£¬µØÖ·ÒëÂëʹÓÃA9-A3
ϵͳʱÖÓΪ12MHZ(Ìáʾ£ºÊ¹Óö¨Ê±Æ÷¶¨Ê±Öжϣ¬²¢Ð´Ã÷¶¨Ê±Æ÷²ÎÊý¼ÆËã¹ý³Ì£»
P074LS373ALE¡Â28031INT1WRP2.0¡Ý1RD1¡Ý11CLKD0~D7EOCABCVref(£«)Vref(£)GA0~A7A0A1A2£«5 VGNDIN0IN1IN2IN3IN4IN5IN6IN7ADC08091STALEOE
ÐÞ¸ÄÉÏͼÖеÄp2.0 ÓÃA3µ½A9ÒëÂ룬²úÉúµØÖ·£º24x8£¬24=0011000 A3-A5½ÓABC£¬A9-A6²úÉú0011Â߼ѡÖÐÒëÂëÆ÷¡£
x=216 - t¡Áfosc/12=2^16-20X12X1000/12=45536=B1E0H ORG 0000H SETB ET1 ¿ªÖжÏÔÊÐí MOV @R1£¬A AJMP MAIN SETB TR1 INC R1 ORG 001BH MOV DPTR, #XX+1 MOV TH1, #0B1H AJMP T_1 MOV A, #00H MOV TL1, #0E0H MAIN: MOVX @DPTR, A;Æô¶¯×ªSETB TR1; Æô¶¯20ms¶¨MOV R4, #10H »» ʱ
SJMP $ SJMP OUT_1 MOV R1£¬#30H
MOV SP, #60H ------------ EXIT:CLR EA ¹ØÖжÏÔÊÐí MOV TOMD, #10H T_1: DJNZ R4 LP1 OUT_1:¡£ MOV TH1, #0B1H SJMP EXIT RETI MOV TL1, #0E0H END LP1£ºCLR TR1
MOV DPTR, #XX+1 20ms¶¨Ê±
SETB EA MOVX A, @DPTR
µÚ8Õ LEDÏÔʾÆ÷ºÍ¼üÅÌ
¼üÅ̵İ´¼ü°´M¡ÁNÐÐÁоØÕóÅÅÁУ¬¹ÊM¡ÁN¸ö¼üµÄ¼üÅÌÖ»ÐèÒªM+NÌõµ¥Æ¬»úµÄI/O¶Ë¿ÚÏß¡£
4¡Á8ÐÐÁÐʽ·Ç±àÂë¼üÅ̵ĽӿÚÈçÏÂÒ³Ëùʾ£º
¼àÊÓ¼üÅÌ·½·¨¡ª¡ªÐÐɨÃè·¨ºÍ·´×ª·¨ CPUͨ¹ý³ÌÐò¼àÊӷDZàÂëÅÌ£¬ÔÚ·¢ÏÖÓа´¼ü°´ÏÂʱתÈëÏàÓ¦°´¼ü´¦Àí³ÌÐòÖ´ÐС£µØÖ·Æ«ÒÆÁ¿N = ÐÐÊ×Öµ + ÁÐÖµ£¬²é¼üÖµ±í¾Í¿ÉµÃ±»°´¼üµÄ¼üÖµ 1.ÐÐɨÃè·¨ 1£©ÅжÏÓÐÎÞ°´¼ü ÁîÁÐÊä³ö£¨PA¿Ú£©È«ÎªÁã,¶ÁÐÐÖµ£¨PC¿Ú£©£¬ÈôÐÐÖµµÍ4λΪȫ1,ÎÞ°´¼ü¡£·ñÔòÓа´¼ü¡£ 2£©ÅжÏÄÄÒ»¸ö¼ü°´ÏÂ
ÂÖÁ÷ɨÃèPA¿Ú£¬ÒÀ´ÎʹÿÌõÁÐÏß±äΪµÍµçƽºó£¬¶ÁÐÐÖµ£¬Èô·ÇÈ«1£¬Ôò°´¼üÔÚ´ËÁÐÖУ¬ÐγɼüÖµ£»·ñÔòɨÃèÏÂÒ»ÁС£ ÓÉ´Ë£¬¿ÉÈ·¶¨°´¼üµÄÐÐÊ×¼üºÅºÍÁÐÖµ£¬½ø¶øÇóµÃ¼üÖµÆ«ÒÆÁ¿¡£
°´¼üÀàÐÍÅбð£º
Èô±»°´¼üµÄ¼üÖµ<10H,±»°´¼üΪÊý×Ö¼ü£» Èô±»°´¼üµÄ¼üÖµ>=10H,±»°´¼üΪ¹¦Äܼü¡£
2.·´×ª·¨
1£©É趨PAΪÊä³ö·½Ê½£¬PCΪÊäÈ뷽ʽ¡£ 2£©Ê¹PAÊä³öÈ«0,¶ÁPC¡££¨PC=1101£© 3£©É趨PAΪÊäÈ뷽ʽ£¬PCΪÊä³ö·½Ê½ 4£©½«¸Õ²Å¶ÁÈëµÄPCÄÚÈÝ´ÓPCÊä³ö¡£(PC=1101) 5£©¶ÁPA¡££¨PA=11111011£© 6£©ÓÉPA¡¢PCµÃµ½¼üÖµ¡£
¹²Òõ¼«£¨1ÁÁ0²»ÁÁ£©£»¹²Ñô¼«£¨0ÁÁ1²»ÁÁ£©
ÀýÌâ1. ÓÃ8155¶Ô¹²ÒõLEDÏÔʾ¿é½øÐпØÖÆ£¬¼ÙÉèÒªÏÔʾ£º2012,1×ÖÑù£¬Ð´³ö¶ÔÓ¦×ÖÐÍÂ룬»Á÷³Ìͼ8155¿ÚµØÖ·ÊÇ9000H¡££¨Í¼ÐΣº8155a¿ÚÊä³öÊý¾Ýc¿ÚÊä³öÁù¸ö¿ØÖÆÎ»£©
¹²Ñô 0c0H,0f9H,0a4H,0b0H,99H,92H,82H,0f8H [8-F] 80H,90H,88H,83H,0c6H,0a1H,86H,8eH ¹²Òõ3FH,06H,5BH,4FH,66H,6DH,7DH,07H [8-F]7FH,6FH ,77H,7CH,39H,5EH,79H,71H,00H
ORG 1000H
ORG 0079H£ºÏÔʾµÄÊý¾Ý¶Î DB
02H,00H,01H,02H,11H,02H
ORG 1000H
DIS: MOV A,#0000 0011B
MOV DPTR,#9000H MOVX @DPTR,A LP1£ºMOV R0£¬#79H
MOV R3£¬#0FEH DIS0: MOV DPTR, #9003H
MOV A #0FFH MOVX @DPTR,A MOV DPTR, #9003H
MOV A,@R0 DB ADD A,#0CH 7FH,6FH,77H,7CH,39H,MOVC A,@A+PC 5EH,79H,71H,00H,80HMOVX @DPTR,A £¨Ð¡Êýµã£© MOV A,R3 ; MOV DPTR,#9001H -------------------------------MOVX @DPTR,A ---- ACALL DELAY DELAY: MOV R7£¬MOV A,R3 #02H JNB ACC.5£¬LP1 MOV R6£¬#0FFH RL A DJNZ R6£¬$ MOV R3£¬A DJNZ R7£¬$-4 INC R0 RET SJMP DIS0 ;------------------------------ DIS_RET: RET; END -------------------------------
TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
ÀýÌâ2. ÓÃ8155¶Ô¼üÅ̽øÐпØÖÆ¡£¼üÅ̵IJ¼¾ÖÈçͼ£¬Çë¸ù¾Ýµç·ͼ£¬¿Éд16¸ö
¼üÅ̵ıàÂ룬Èô°´¼üΪA,Ôòת´òÓ¡³ÌÐòPRINT,»³ö¼üÅÌɨÃèµÄ³ÌÐòÁ÷³Ìͼ¡£
¼üÖµ ¼üÃû 0 1 2 3 4 5 6 7 8 9 A B C D E F ¼üÖµ 12 8 4 0 13 9 5 1 14 10 6 2 15 11 7 3 ¼üÅÌλÖÃͼ 0 1 2 3 4 5 6 7 8 9 A B C D E F