|
±¾½Ì³ÌÓɴŶ¯Á¦¹¤×÷ÊÒµÄÕ¾³¤Ã÷ºÆ±àд
|
µÚÎå¿Î¡¡³£Á¿ |
¡¡¡¡ÉÏÒ»½ÚÎÒÃÇѧϰÁËKEIL C51±àÒëÆ÷ËùÖ§³ÖµÄÊý¾ÝÀàÐÍ¡£¶øÕâЩÊý¾ÝÀàÐÍÓÖÊÇÔõôÓÃÔÚ³£Á¿ºÍ±äÁ¿µÄ¶¨ÒåÖеÄÄØ£¿ÓÖÓÐʲôҪעÒâµÄÂð£¿ÏÂÃæ¾ÍÀ´¿´¿´°É¡£ÔΣ¡Ä㻹Çø·Ö²»Çå³þʲôÊdz£Á¿£¬Ê²Ã´ÊDZäÁ¿¡£³£Á¿ÊÇÔÚ³ÌÐòÔËÐйý³ÌÖв»ÄܸıäÖµµÄÁ¿£¬¶ø±äÁ¿ÊÇ¿ÉÒÔÔÚ³ÌÐòÔËÐйý³ÌÖв»¶Ï±ä»¯µÄÁ¿¡£±äÁ¿µÄ¶¨Òå¿ÉÒÔʹÓÃËùÓÐC51±àÒëÆ÷Ö§³ÖµÄÊý¾ÝÀàÐÍ£¬¶ø³£Á¿µÄÊý¾ÝÀàÐÍÖ»ÓÐÕûÐÍ¡¢¸¡µãÐÍ¡¢×Ö·ûÐÍ¡¢×Ö·û´®ÐͺÍλ±êÁ¿¡£ÕâÒ»½ÚÎÒÃÇѧϰ³£Á¿¶¨ÒåºÍÓ÷¨£¬¶øÏÂÒ»½ÚÔòѧϰ±äÁ¿¡£
³£Á¿µÄÊý¾ÝÀàÐÍ˵Ã÷ÊÇÕâÑùµÄ
¡¡¡¡1£® ÕûÐͳ£Á¿¿ÉÒÔ±íʾΪʮ½øÖÆÈç123,0£¬£89µÈ¡£Ê®Áù½øÖÆÔòÒÔ0x¿ªÍ·Èç0x34,-0x3BµÈ¡£³¤ÕûÐ;ÍÔÚÊý×ÖºóÃæ¼Ó×ÖĸL£¬Èç104L£¬034L£¬0xF340µÈ¡£
¡¡¡¡2£® ¸¡µãÐͳ£Á¿¿É·ÖΪʮ½øÖƺÍÖ¸Êý±íʾÐÎʽ¡£Ê®½øÖÆÓÉÊý×ÖºÍСÊýµã×é³É£¬Èç0.888,3345.345,0.0µÈ£¬ÕûÊý»òСÊý²¿·ÖΪ0£¬¿ÉÒÔÊ¡ÂÔµ«±ØÐëÓÐСÊýµã¡£Ö¸Êý±íʾÐÎʽΪ[¡À]Êý×Ö[.Êý×Ö]e[¡À]Êý×Ö£¬[]ÖеÄÄÚÈÝΪ¿ÉÑ¡ÏÆäÖÐÄÚÈݸù¾Ý¾ßÌåÇé¿ö¿ÉÓпÉÎÞ£¬µ«ÆäÓಿ·Ö±ØÐëÓÐ,Èç125e3,7e9,-3.0e-3¡£
¡¡¡¡3£® ×Ö·ûÐͳ£Á¿Êǵ¥ÒýºÅÄÚµÄ×Ö·û£¬Èç'a','d'µÈ£¬²»¿ÉÒÔÏÔʾµÄ¿ØÖÆ×Ö·û£¬¿ÉÒÔÔÚ¸Ã×Ö·ûÇ°Ãæ¼ÓÒ»¸ö·´Ð±¸Ü"\"×é³ÉרÓÃתÒå×Ö·û¡£³£ÓÃתÒå×Ö·û±íÇë¿´±í5£1¡£
¡¡¡¡4£® ×Ö·û´®Ðͳ£Á¿ÓÉË«ÒýºÅÄÚµÄ×Ö·û×é³É£¬Èç"test","OK"µÈ¡£µ±ÒýºÅÄÚµÄûÓÐ×Ö·ûʱ£¬Îª¿Õ×Ö·û´®¡£ÔÚʹÓÃÌØÊâ×Ö·ûʱͬÑùҪʹÓÃתÒå×Ö·ûÈçË«ÒýºÅ¡£ÔÚCÖÐ×Ö·û´®³£Á¿ÊÇ×öΪ×Ö·ûÀàÐÍÊý×éÀ´´¦ÀíµÄ£¬ÔÚ´æ´¢×Ö·û´®Ê±ÏµÍ³»áÔÚ×Ö·û´®Î²²¿¼ÓÉÏ\oתÒå×Ö·ûÒÔ×÷Ϊ¸Ã×Ö·û´®µÄ½áÊø·û¡£×Ö·û´®³£Á¿"A"ºÍ×Ö·û³£Á¿'A'ÊDz»Í¬µÄ£¬Ç°ÕßÔڴ洢ʱ¶àÕ¼ÓÃÒ»¸ö×Ö½ÚµÄ×ּ䡣
¡¡¡¡5£® λ±êÁ¿£¬ËüµÄÖµÊÇÒ»¸ö¶þ½øÖÆ¡£ |
תÒå×Ö·û |
º¬Òå |
ASCIIÂ루16/10½øÖÆ£© |
\o |
¿Õ×Ö·û(NULL) |
00H/0 |
\n |
»»Ðзû(LF) |
0AH/10 |
\r |
»Ø³µ·û(CR) |
0DH/13 |
\t |
ˮƽÖƱí·û(HT) |
09H/9 |
\b |
Í˸ñ·û(BS) |
08H/8 |
\f |
»»Ò³·û(FF) |
0CH/12 |
\' |
µ¥ÒýºÅ |
27H/39 |
\" |
Ë«ÒýºÅ |
22H/34 |
\\ |
·´Ð±¸Ü |
5CH/92 |
±í5£1¡¡³£ÓÃתÒå×Ö·û±í
|
¡¡¡¡³£Á¿¿ÉÓÃÔÚ²»±Ø¸Ä±äÖµµÄ³¡ºÏ£¬Èç¹Ì¶¨µÄÊý¾Ý±í£¬×Ö¿âµÈ¡£³£Á¿µÄ¶¨Ò巽ʽÓм¸ÖÖ,ÏÂÃæÀ´¼ÓÒÔ˵Ã÷¡£
#difine False 0x0; //ÓÃÔ¤¶¨ÒåÓï¾ä¿ÉÒÔ¶¨Òå³£Á¿
#difine True 0x1; //ÕâÀﶨÒåFalseΪ0,TrueΪ1
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÔÚ³ÌÐòÖÐÓõ½False±àÒëʱ×Ô¶¯ÓÃ0Ìæ»»£¬Í¬ÀíTrueÌ滻Ϊ1
unsigned int code a=100; //ÕâÒ»¾äÓÃcode°Ña¶¨ÒåÔÚ³ÌÐò´æ´¢Æ÷Öв¢¸³Öµ
const unsigned int c=100; //ÓÃconst¶¨ÒåcΪÎÞ·ûºÅint³£Á¿²¢¸³Öµ
¡¡¡¡ÒÔÉÏÁ½¾äËüÃǵÄÖµ¶¼±£´æÔÚ³ÌÐò´æ´¢Æ÷ÖУ¬¶ø³ÌÐò´æ´¢Æ÷ÔÚÔËÐÐÖÐÊDz»ÔÊÐí±»Ð޸ĵģ¬ËùÒÔÈç¹ûÔÚÕâÁ½¾äºóÃæÓÃÁËÀàËÆa=110£¬a++ÕâÑùµÄ¸³ÖµÓï¾ä£¬±àÒëʱ½«»á³ö´í¡£
˵ÁËһͨ»¹²»Èçд¸ö³ÌÐòÀ´ÊµÑéһϰɡ£Ð´Ê²Ã´³ÌÐòÄØ£¿ÅÜÂíµÆ£¡¶Ô£¬¾ÍдÕâ¸ö¼òµ¥Ò׶®µÄ°É£¬Õâ¸öÒ²ºÃ˵Ã÷µäÐ͵ij£Á¿Ó÷¨¡£ÏÈÀ´¿´¿´µç·ͼ°É¡£ËüÊÇÔÚÎÒÃÇÉÏÒ»¿ÎµÄʵÑéµç·µÄ»ù´¡ÉÏÔö¼Ó6¸öLED×é³ÉµÄ£¬Ò²¾ÍÊÇÓÃP1¿ÚµÄÈ«²¿Òý½Å·Ö±ðÇý¶¯Ò»¸öLED£¬µç·Èçͼ5£1Ëùʾ¡£
¡¡¡¡Ð½¨Ò»¸öRunLEDµÄÏîÄ¿£¬Ö÷³ÌÐòÈçÏ£º
#include <AT89X51.H> //Ô¤´¦ÀíÎļþÀïÃ涨ÒåÁËÌØÊâ¼Ä´æÆ÷µÄÃû³ÆÈçP1¿Ú¶¨ÒåΪP1
void main(void)
{
//¶¨Ò廨ÑùÊý¾Ý
cons tunsigned char design[32]={0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,
0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x0,
0xE7,0xDB,0xBD,0x7E,0xFF};
unsigned int a; //¶¨ÒåÑ»·ÓõıäÁ¿
unsigned char b; //ÔÚC51±à³ÌÖÐÒòÄÚ´æÓÐÏÞ¾¡¿ÉÄÜ×¢Òâ±äÁ¿ÀàÐ͵ÄʹÓÃ
//¾¡¿ÉÄÜʹÓÃÉÙ×Ö½ÚµÄÀàÐÍ£¬ÔÚ´óÐ͵ijÌÐòÖкÜÊÜÓÃ
do{
for (b=0; b<32; b++)
{
for(a=0; a<30000; a++); //ÑÓʱһ¶Îʱ¼ä
P1 = design[b]; //¶ÁÒѶ¨ÒåµÄ»¨ÑùÊý¾Ý²¢Ð´»¨ÑùÊý¾Ýµ½P1¿Ú
}
}while(1);
}
¡¡¡¡³ÌÐòÖеĻ¨ÑùÊý¾Ý¿ÉÒÔ×ÔÒÔÈ¥¶¨Òå,ÒòÕâÀïÎÒÃǵÄLEDÒªAT89C51µÄP1Òý½ÅΪµÍµçƽ²Å»áµãÁÁ£¬ËùÒÔÎÒÃÇÒªÏòP1¿ÚµÄ¸÷Òý½ÅдÊý¾ÝO¶ÔÓ¦Á¬½ÓµÄLED²Å»á±»µãÁÁ£¬P1¿ÚµÄ°Ë¸öÒý½Å¸ÕºÃ¶ÔÓ¦P1¿ÚÌØÊâ¼Ä´æÆ÷µÄ°Ë¸ö¶þ½ø룬ÈçÏòP1¿Ú¶¨Êý¾Ý0xFE,ת³É¶þ½øÖƾÍÊÇ11111110,×îµÍλD0Ϊ0ÕâÀïP1.0Òý½ÅÊä³öµÍµçƽ£¬LED1±»µãÁÁ¡£Èç´ËÀàÍÆ£¬´ó¼Ò²»ÄÑËã³ö×Ô¼ºÏëÒª×öµÄЧ¹ûÁË¡£´ó¼Ò±àÒëÉÕд¿´¿´£¬Ð§¹û¾Í³öÀ´£¬ÏÔʾµÄËÙ¶ÈÄú¿ÉÒÔ¸ù¾ÝÐèÒªµ÷ÕûÑÓʱaµÄÖµ£¬²»Òª³¬¹ý±äÁ¿ÀàÐ͵ÄÖµÓò¾ÍºÜÐÐÁË¡£Å¶£¬Äú»¹Ã»ÓÐʵÑé°å£¿ÄÇÈçºÎ¿ÉÒÔÖªµÀ³ÌÐòÔËÐеĽá¹ûÄØ£¿ºÇ£¬²»Óü±£¬Õâ¾ÍÀ´ËµËµÓÃKEIL
uVision2µÄÈí¼þ·ÂÕæÀ´µ÷ÊÔIO¿ÚÊä³öÊäÈë³ÌÐò¡£ |
ͼ5£1¡¡°Ë·ÅÜÂíµÆµç·
|
¡¡¡¡±àÒëÔËÐÐÉÏÃæµÄ³ÌÐò£¬È»ºó°´ÍⲿÉ豸²Ëµ¥Peripherals£I/O Ports£Port1¾Í´ò¿ªPort1µÄµ÷ÊÔ´°¿ÚÁË£¬Èçͼ5£3ÖеÄ2¡£Õâʱ³ÌÐòÔËÐÐÁË£¬µ«ÎÒÃDz¢²»ÄÜÔÚPort1µ÷ÊÔ´°¿ÚÉÏ¿´µ½ÓлáʲôЧ¹û£¬ÕâʱÎÒÃÇ¿ÉÒÔÓÃÊó±ê×ó»÷ͼ5£3ÖÐ1ÅÔ±ßÂÌÉ«µÄ·½Ìõ£¬µãһϾÍÓÐÒ»¸öСºì·½¸ñÔÚµãÒ»ÏÂÓÖûÓÐÁË£¬ÄÄÒ»¾äÓï¾äÇ°ÓÐС·½¸ñ³ÌÐòÔËÐе½ÄÇÒ»¾äʱ¾ÍÍ£Ö¹ÁË£¬¾ÍÊÇÉèÖõ÷ÊԶϵ㣬ͬÑùͼ5£2ÖеÄ1Ò²ÊÇͬÑù¹¦ÄÜ£¬·Ö±ðÊÇÔö¼Ó/ÒƳý¶Ïµã¡¢ÒƳýËùÓжϵ㡢ÔÊÐí/½ûÖ¹¶Ïµã¡¢½ûÖ¹ËùÓжϵ㣬²Ëµ¥Ò²ÓÐÒ»ÑùµÄ¹¦ÄÜ£¬ÁíÍâ²Ëµ¥Öл¹ÓÐBreakpoints¿É´ò¿ª¶ÏµãÉèÖô°¿ÚËüµÄ¹¦ÄܸüÇ¿´ó£¬²»¹ýÎÒÃÇÕâÀïÏȲ»ÓÃËü¡£ÎÒÃÇÔ"P1
= design[b];"ÕâÒ»¾äÉèÖÃÒ»¸ö¶ÏµãÕâʱ³ÌÐòÔËÐе½ÕâÀï¾ÍͣסÁË£¬ÔÙÁôÒâÒ»ÏÂPort1µ÷ÊÔ´°¿Ú£¬ÔÙ°´Í¼5-2ÖеÄ2µÄÔËÐмü£¬³ÌÐòÓÖÔËÐе½ÉèÖöϵãµÄµØ·½Í£×¡ÁË£¬ÕâʱPort1µ÷ÊÔ´°¿ÚµÄ״̬ÓÖ²»Í¬ÁË¡£Ò²¾ÍÊÇ˵Port1µ÷ÊÔ´°¿ÚÄ£ÄâÁËP1¿ÚµÄµçƽ״̬£¬´ò¹´Îª¸ßµçƽ£¬²»´ò¹´ÔòΪµÍµçƽ£¬´°¿ÚÖÐP1ΪP1¼Ä´æÆ÷µÄ״̬£¬PinsΪÒý½ÅµÄ״̬£¬×¢ÒâµÄÊÇÈç¹ûÊǶÁÒý½ÅÖµ±ØÐë°ÑÒý½Å¶ÔÓ¦µÄ¼Ä´æÆ÷ÖÃ1²ÅÄÜÕýÈ·¶ÁÈ¡¡£Í¼5£2ÖÐ2ÅԱߵģû£ýÑùµÄ°´Å¥·Ö±ðΪµ¥²½È룬²½Ô½£¬²½³öºÍÖ´Ðе½µ±Ç°ÐС£Í¼ÖÐ3ΪÏÔʾÏÂÒ»¾ä½«ÒªÖ´ÐеÄÓï¾ä¡£Í¼5£3ÖеÄ3ÊÇWatches´°¿Ú¿É²é¿´¸÷±äÁ¿µÄµ±Ç°Öµ£¬Êý×éºÍ×Ö´®ÊÇÏÔʾÆäÍ·Ò»¸öµØÖ·£¬Èç±¾ÀýÖеÄdesignÊý×éÊDZ£´æÔÚcode´æ´¢ÇøµÄÊ×µØַΪD:0x08,¿ÉÒÔÔÚͼÖÐ4
Memory´æ´¢Æ÷²é¿´´°¿ÚÖеÄAddressµØÖ·ÖдòÈëD:0x08¾Í¿ÉÒԲ鿴µ½design¸÷Êý¾ÝºÍ´æ·ÅµØÖ·ÁË¡£Èç¹ûÄãµÄuVision2ûÓÐÏÔʾÕâЩ´°¿Ú£¬¿ÉÒÔÔÚView²Ëµ¥Öдò¿ªÔÚͼ5£2ÖÐ3ºóÃæÒ»À¸µÄ²é¿´´°¿Ú¿ì½ÝÀ¸Öдò¿ª¡£
|
ͼ5£2¡¡µ÷ÊÔÓÿì½Ý²Ëµ¥À¸ |
ͼ5£3¡¡¸÷µ÷ÊÔ´°¿Ú |
|
µã»÷½øÈ뵥Ƭ»úCÓïÑԽ̵̳ÄÏÂÒ»¿Î
·µ»Ø¡¶µç×ÓÖÆ×÷ʵÑéÊÒ¡·ÍøÕ¾Ö÷Ò³
|