DEC R1
DJNZ R2£¬LOOP END
£±£³¡¢ ±àдһ³ÌÐò¶Î£¬Æä¹¦ÄÜΪ£ºÄÚ²¿RAMµÄ32H£¨¸ß£©~30H£¨µÍ£©ºÍ35H£¨¸ß£©~33H£¨µÍ£©Á½¸öÈý×Ö½ÚÎÞ·ûºÅÊýÏà¼Ó£¬½á¹û´æÈë32H£¨¸ß£©~30H£¨µÍ£©µ¥Ôª£¬ÉèÈý×Ö½ÚÏà¼ÓʱÎÞ½øÎ»¡££¨10·Ö£© MOV R0£¬#30H MOV R1£¬#33H MOV R2£¬#03H CLR C
LOOP£ºMOV A£¬@R0 ADDC A£¬@R1 MOV @R0£¬A INC R0 INC R1
DJNZ R2£¬LOOP END
£±£´¡¢ ±àдһ³ÌÐò¶Î£¬Æä¹¦ÄÜΪ£ºÄÚ²¿RAMµÄ30H£¨¸ß£©~32H£¨µÍ£©ºÍ33H£¨¸ß£©~35H£¨µÍ£©Á½¸öÈý×Ö½ÚÎÞ·ûºÅÊýÏà¼õ£¬½á¹û´æÈë30H£¨¸ß£©~32H£¨µÍ£©µ¥Ôª£¬ÉèÈý×Ö½ÚÏà¼õʱÎÞ½øÎ»¡££¨10·Ö£© MOV R0£¬#32H MOV R1£¬#35H MOV R2£¬#03H CLR C
LOOP£ºMOV A£¬@R0 SUBB A£¬@R1 MOV @R0£¬A DEC R0 DEC R1
DJNZ R2£¬LOOP END
£±£µ¡¢ ±àдһ³ÌÐò¶Î£¬Æä¹¦ÄÜΪ£ºÄÚ²¿RAMµÄ43H£¨¸ß£©~40H£¨µÍ£©ºÍ33H£¨¸ß£©~30H£¨µÍ£©Á½¸öËÄ×Ö½ÚÎÞ·ûºÅÊýÏà¼õ£¬½á¹û´æÈë43H£¨¸ß£©~40H£¨µÍ£©µ¥Ôª£¬ÉèËÄ×Ö½ÚÏà¼õʱÎÞ½øÎ»¡££¨10·Ö£© MOV R0£¬#40H MOV R1£¬#30H MOV R2£¬#04H CLR C
LOOP£ºMOV A£¬@R0 SUBB A£¬@R1 MOV @R0£¬A INC R0
INC R1
DJNZ R2£¬LOOP END
£±£¶¡¢ ±àдһ³ÌÐò¶Î£¬½«ÄÚ²¿RAM30H¡«3FHµÄÄÚÈÝ´«Ë͵½ÍⲿRAMµÄ8000H¡«800FHÖС£
MOV R0£¬#30H
MOV DPTR£¬#8000H MOV R2£¬#10H
LOOP£ºMOV A£¬@R0 MOVX @DPTR£¬A INC R0 INC DPTR
DJNZ R2£¬LOOP END
Èý¡¢ ×ÛºÏÌâ
£±¡¢ ÒÑÖªÕñµ´Æ÷Õñµ´ÆµÂÊfoscΪ12MHz£¬ÒªÇó¶¨Ê±Æ÷/¼ÆÊýÆ÷0²úÉú10ms¶¨Ê±£¬±àд³õʼ»¯³ÌÐò¡£ ½â£º
(1) ÒÑÖª¶¨Ê±Ê±¼ä´óÓÚ8192¦Ìs£¬, Òª¶¨Ê±Æ÷/¼ÆÊýÆ÷0ӦѡÓù¤×÷·½Ê½1. £Ô£È£°¡¢£Ô£È£±³õÖµ¼ÆËã £Ôcy=12¡Á(1/(12¡Á106))£½£±¦Ìs
ËùÒÔ£Ô£½£¨65536-X£©£Ôcy=£¨65536-X£©¡Á£±¦Ìs=10ms x=55536=D8F0H
(2) ·½Ê½¼Ä´æÆ÷µÄ±à³Ì£º
£Ô£Í£Ï£ÄµÄ¸÷λÄÚÈÝÈ·¶¨ÈçÏ£ºÓÉÓÚ¶¨Ê±Æ÷/¼ÆÊýÆ÷0É趨Ϊ¹¤×÷·½Ê½1,·ÇÃſط½Ê½£¬ËùÒÔC/T(TMOD.2)=0£¬M!( TMOD.1)=0£¬M0( TMOD.0)=1£¬GATE!( TMOD.£³)=0£»¶¨Ê±Æ÷£¯¼ÆÊýÆ÷1ûÓÐʹÓã¬ÏàÓ¦µÄ£Ä£·££Ä£´ÎªËæÒâ̬¡°£Ø¡±¿ÉȡΪ0£¬Ôò( TMOD)=0£±£È (3) ³õʼ»¯³ÌÐò
Start: MOV TL0, #F0H; MOV TH0, #D8H; MOV TMOD, #01H; SETB TR0
£²¡¢ ÈôFosc=6MHz£¬ÓÃT0²úÉú5ms¶¨Ê±£¬±àд³õʼ»¯³ÌÐò¡£(Ñ¡Óù¤×÷·½Ê½0) ½â£º
¶¨Ê±Æ÷/¼ÆÊýÆ÷0Ñ¡Óù¤×÷·½Ê½0ʱ (1)£Ô£È£°¡¢£ÔL0³õÖµ¼ÆËã
£Ôcy=6¡Á(1/(12¡Á106))£½2¦Ìs
ËùÒÔ£Ô£½£¨8192-X£©£Ôcy=£¨8192-X£©¡Á2¦Ìs=5ms=5000¦Ìs x=5692=163CH TH0=B1H£»TL0=1CH (2) ·½Ê½¿ØÖƼĴæÆ÷µÄ±à³Ì£º
£Ô£Í£Ï£ÄµÄ¸÷λÄÚÈÝÈ·¶¨ÈçÏ£ºÓÉÓÚ¶¨Ê±Æ÷/¼ÆÊýÆ÷0É趨Ϊ¹¤×÷·½Ê½0,·ÇÃſط½Ê½£¬ËùÒÔC/T(TMOD.2)=0£¬M!( TMOD.1)=0£¬M0( TMOD.0)=0£¬GATE!( TMOD.£³)=0£»¶¨Ê±Æ÷£¯¼ÆÊýÆ÷1ûÓÐʹÓã¬ÏàÓ¦µÄ£Ä£·££Ä£´ÎªËæÒâ̬¡°£Ø¡±¿ÉȡΪ0£¬Ôò( TMOD)=00£È (4) ³õʼ»¯³ÌÐò
Start: MOV TL0, #1CH; MOV TH0, #B1H; MOV TMOD, #00H; SETB TR0
£³¡¢ ÒÑÖªµ¥Æ¬»úµÄ¾§ÕñƵÂÊfosc=6MHz£¬ÒªÇó¶¨Ê±ÖµÎª0.1ms¶¨Ê±£¬¶¨Ê±Æ÷£Ô£°¹¤×÷ÔÚ·½Ê½0¡¢·½Ê½£±¡¢·½Ê½£²Ê±£¬¶¨Ê±Æ÷É趨µÄ³õÖµ¸÷Ϊ¶àÉÙ£¿±àд·½Ê½0ʱµÄ³õʼ»¯³ÌÐò¡£ ½â£º
£Ôcy=6¡Á(1/(12¡Á106))£½2¦Ìs£»
¹Ê¶¨Ê±ÖµÎª0.1msʱ£¬¼ÆÊýֵΪ:N=0.1ms/2¦Ìs=50 £¨£±£© ·½Ê½0ʱ£¬³õÖµ£Ø£½213-N=8192-50=8142=1FCEH ¹ÊÉ趨µÄ³õÖµTH0=FEH£»TL0=0EH £¨£²£© ·½Ê½£±Ê±£¬³õÖµ£Ø£½2£±£¶-N=65536-50=65486=FFCEH ¹ÊÉ趨µÄ³õÖµTH0=FFH£»TL0=CEH
£¨£³£© ·½Ê½2ʱ£¬³õÖµ£Ø£½28-N=256-50=206=CEH ¹ÊÉ趨µÄ³õÖµTH0=TL0=CEH
£¨£´£© ·½Ê½0ʱ·½Ê½¿ØÖƼĴæÆ÷µÄ±à³Ì£º
£Ô£Í£Ï£ÄµÄ¸÷λÄÚÈÝÈ·¶¨ÈçÏ£ºÓÉÓÚ¶¨Ê±Æ÷/¼ÆÊýÆ÷0É趨Ϊ¹¤×÷·½Ê½0,·ÇÃſط½Ê½£¬ËùÒÔC/T(TMOD.2)=0£¬M!( TMOD.1)=0£¬M0( TMOD.0)=0£¬GATE!( TMOD.£³)=0£»¶¨Ê±Æ÷£¯¼ÆÊýÆ÷1ûÓÐʹÓã¬ÏàÓ¦µÄ£Ä£·££Ä£´ÎªËæÒâ̬¡°£Ø¡±¿ÉȡΪ0£¬Ôò( TMOD)=00£È £¨£µ£©³õʼ»¯³ÌÐò
Start: MOV TL0, #0EH; MOV TH0, #FEH; MOV TMOD, #00H; SETB TR0
£´¡¢ ÒÑÖªµ¥Æ¬»úµÄ¾§ÕñƵÂÊfosc=6MHz£¬ÒªÇó¶¨Ê±ÖµÎª1ms¶¨Ê±£¬¶¨Ê±Æ÷£Ô£°¹¤×÷ÔÚ·½Ê½0¡¢·½Ê½£±¡¢·½Ê½£²Ê±£¬¶¨Ê±Æ÷É趨µÄ³õÖµ¸÷Ϊ¶àÉÙ£¿±àд·½Ê½0ʱµÄ³õʼ»¯³ÌÐò¡£
½â£º
£Ôcy=6¡Á(1/(12¡Á106))£½2¦Ìs£»
¹Ê¶¨Ê±ÖµÎª1msʱ£¬¼ÆÊýֵΪ:N=1ms/2¦Ìs=500 £¨£±£©·½Ê½0ʱ£¬³õÖµ£Ø£½213-N=8192-500=7692=1E0CH
¹ÊÉ趨µÄ³õÖµTH0=F0H£»TL0=0CH £¨£²£© ·½Ê½£±Ê±£¬³õÖµ£Ø£½2£±£¶-N=65536-500=65036=FE0CH ¹ÊÉ趨µÄ³õÖµTH0=FEH£»TL0=0CH
£¨£³£© ·½Ê½2ʱ£¬²»ÄÜ´ïµ½1ms¶¨Ê±¡£ £¨£´£© ·½Ê½0ʱ·½Ê½¿ØÖƼĴæÆ÷µÄ±à³Ì£º
£Ô£Í£Ï£ÄµÄ¸÷λÄÚÈÝÈ·¶¨ÈçÏ£ºÓÉÓÚ¶¨Ê±Æ÷/¼ÆÊýÆ÷0É趨Ϊ¹¤×÷·½Ê½0,·ÇÃſط½Ê½£¬ËùÒÔC/T(TMOD.2)=0£¬M!( TMOD.1)=0£¬M0( TMOD.0)=0£¬GATE!( TMOD.3)=0£»¶¨Ê±Æ÷£¯¼ÆÊýÆ÷1ûÓÐʹÓã¬ÏàÓ¦µÄ£Ä£·££Ä£´ÎªËæÒâ̬¡°£Ø¡±¿ÉȡΪ0£¬Ôò( TMOD)=00£È £¨£µ£©³õʼ»¯³ÌÐò
Start: MOV TL0, #0CH; MOV TH0, #F0H; MOV TMOD, #00H; SETB TR0
£µ¡¢ 8031оƬµÄINT0¡¢INT1Òý½Å·Ö±ðÊäÈëѹÁ¦³¬ÏÞ¼°Î¶ȳ¬ÏÞÖжÏÇëÇóÐźţ¬¶¨Ê±Æ÷/¼ÆÊýÆ÷0×÷¶¨Ê±¼ì²âµÄʵʱʱÖÓ£¬Óû§¹æ¶¨µÄÖжÏÓÅÏÈȨÅŶӴÎÐòΪ£º ѹÁ¦³¬ÏÞ Î¶ȳ¬ÏÞ ¶¨Ê±¼ì²â ÒªÇóÈ·¶¨IE¡¢IPµÄÄÚÈÝ£¬ÒÔʵÏÖÉÏÊöÒªÇó¡£ ½â£º
(1)ÖжϿØÖƼĴæÆ÷¸÷붨Ò壺£Ä£·£º£Ã£Ð£ÕÖжÏÔÊÐíλEA£¬Ó¦ÉèΪ1 £Ä£¶£ºÎ´¶¨Ò壬¿ÉÎªËæÒâÁ¿,ȡΪ0
£Ä£µ£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷£²ÖжÏÔÊÐíλ£Å£Ô£²,¿ÉÈ¡0 D4£º´®ÐпÚÖжÏÔÊÐíλ£Å£Ó, ¿ÉÈ¡0
D£³£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷£±ÖжÏÔÊÐíλ£Å£Ô£±, Ӧȡ0 D2£ºÍⲿÖжϣ±ÖжÏÔÊÐíλ£ÅX£±, Ӧȡ1
D1£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷0ÖжÏÔÊÐíλ£Å£Ô0, Ӧȡ1 D0£ºÍⲿÖжÏ0ÖжÏÔÊÐíλ£ÅX0, Ӧȡ1 ¹ÊIE=87H
(2)ÓÉÓ²¼þÈ·¶¨µÄͬһÓÅÏȼ¶ÖжÏÔ´µÄÓÅÏÈȨÅŶÓ˳ÐòÈçÏ£º £É£Î£Ô£°££Ã£¯£Ô£°££É£Î£Ô£±££Ã£¯T1£´®ÐпÚÖжϣc/£²
£Í£Ã£Ó££µ£±ÓÐÁ½¸öÖжÏÓÅÏȼ¶,ÖжÏÓÅÏÈȨѡÔñ¼Ä´æÆ÷£É£Ð¿É¶Ô¸÷ÖжÏÔ´ÓÃÈí¼þ½øÐбà³Ì,È·¶¨Îª¸ßÓÅÏȼ¶Öжϻ¹ÊǵÍÓÅÏȼ¶Öжϡ£ÒòЩ¿ÉÒÔÓÃÓ²¼þÓëÈí¼þÏà½áºÏµÄ·½·¨¶ÔÖжÏÔ´µÄÓÅÏȼ¶½øÐÐÅÅÐò¡£
ÓÉÌâÒ⣬¸ù¾Ý£É£Ð¸÷λµÄ¶¨Ò壺£Ä£·£ºÎ´¶¨Ò壬¿ÉÎªËæÒâÁ¿,ȡΪ0 £Ä£¶£ºÎ´¶¨Ò壬¿ÉÎªËæÒâÁ¿,ȡΪ0
£Ä£µ£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷£²ÓÅÏÈȨѡÔñλ£Ð£Ô£²,¿ÉÈ¡0 D4£º´®ÐпÚÓÅÏÈȨѡÔñλ£Ð£Ó, ¿ÉÈ¡0
D£³£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷£±ÓÅÏÈȨѡÔñλ£Ð£Ô£±, Ӧȡ0 D2£ºÍⲿÖжϣ±ÓÅÏÈȨѡÔñλ£ÐX£±, Ӧȡ1£¬Ó¦½Óζȳ¬ÏÞÐźš£
D1£º¶¨Ê±Æ÷£¯¼ÆÊýÆ÷0ÓÅÏÈȨѡÔñλ£Ð£Ô0, ÓÉÓÚÆäÓÅÏȼ¶×îµÍ£¬ËùÒÔӦȡ0 D0£ºÍⲿÖжÏ0ÓÅÏÈȨѡÔñλ£ÐX0, Ӧȡ1£¬Ó¦½ÓѹÁ¦³¬ÏÞÐźš£
¹ÊIP=05H
£¶¡¢ ʲôÊÇ×îСϵͳ£¿8032µ¥Æ¬»úÔÚʹÓÃʱΪʲôҪ×é³É×îСϵͳ²ÅÄÜʹÓã¿×î