{"id":2106,"date":"2019-01-17T13:36:22","date_gmt":"2019-01-17T13:36:22","guid":{"rendered":""},"modified":"2019-01-17T21:37:16","modified_gmt":"2019-01-17T13:37:16","slug":"c51%e5%8d%95%e7%89%87%e6%9c%baled%e6%95%b0%e7%a0%81%e7%ae%a1%e8%ae%a1%e6%95%b0%e5%99%a8%e7%9a%84%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2106","title":{"rendered":"C51\u5355\u7247\u673aLED\u6570\u7801\u7ba1\u8ba1\u6570\u5668\u7684\u8bbe\u8ba1"},"content":{"rendered":"

\n\t\u8be5\u90e8\u5206\u7684\u786c\u4ef6\u7535\u8def\u5982\u56fe\u6240\u793a\uff0cU1\u7684P0\u53e3\u548cP2\u53e3\u7684\u90e8\u4efd\u5f15\u811a\u6784\u6210\u4e866\u4f4dLED\u6570\u7801\u7ba1\u9a71\u52a8\u7535\u8def\uff0c\u6570\u7801\u7ba1\u91c7\u7528\u5171\u9633\u578b\uff0c\u4f7f\u7528PNP\u578b\u4e09\u6781\u7ba1<\/u>\u4f5c\u4e3a\u7247\u9009\u7aef\u7684\u9a71\u52a8\uff0c\u6240 \u6709\u4e09\u6781\u7ba1\u7684\u53d1\u5c04\u6781\u8fde\u5728\u4e00\u8d77\uff0c\u63a5\u5230\u6b63\u7535\u6e90\u7aef\uff0c\u5b83\u4eec\u7684\u57fa\u6781\u5219\u5206\u522b\u8fde\u5230P2.0…P2.5\uff0c\u5f53P2.0…P2.5\u4e2d\u67d0\u5f15\u811a\u8f93\u662f\u4f4e\u7535\u5e73\u65f6\uff0c\u4e09\u6781\u7ba1\u5bfc\u901a\uff0c\u7ed9\u76f8\u5e94\u7684\u6570 \u7801\u7ba1\u4f9b\u7535\uff0c\u8be5\u4f4d\u6570\u7801\u7ba1\u70b9\u4eae\u54ea\u4e9b\u7b14\u6bb5\uff0c\u5219\u53d6\u51b3\u4e8e\u7b14\u6bb5\u5f15\u811a\u662f\u9ad8\u6216\u4f4e\u7535\u5e73\u3002\u56fe\u4e2d\u770b\u51fa\uff0c\u6240\u67096\u4f4d\u6570\u7801\u7ba1\u7684\u7b14\u6bb5\u8fde\u5728\u4e00\u8d77\uff0c\u901a\u8fc7\u9650\u6d41\u7535\u963b\u540e\u63a5\u5230P0\u53e3\uff0c\u56e0\u6b64\uff0c\u54ea\u4e9b\u7b14\u6bb5 \u4eae\u5c31\u53d6\u51b3\u4e8eP0\u53e3\u76848\u6839\u7ebf\u7684\u72b6\u6001\u3002<\/p>\n

\n\t\"C51\u5355\u7247\u673aLED\u6570\u7801\u7ba1\u8ba1\u6570\u5668\u7684\u8bbe\u8ba1\"<\/p>\n

\n\t <\/div>\n

\n\t\u7f16\u5199\u7a0b\u5e8f\u65f6\uff0c\u9996\u5148\u6839\u636e\u786c\u4ef6\u8fde\u7ebf\u5199\u51faLED\u6570\u7801\u7ba1\u7684\u5b57\u5f62\u7801\u3001\u4f4d\u9a71\u52a8\u7801\uff0c\u7136\u540e\u7f16\u5199\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>\n

\n\t#include “reg51.h”<\/p>\n

\n\t#define uchar unsigned char<\/p>\n

\n\t#define uint unsigned int<\/p>\n

\n\tuchar code BitTab\uff3b\uff3d={0x7F\uff0c0xBF\uff0c0xDF\uff0c0xEF\uff0c0xF7\uff0c0xFB};\u3000\/\/\u4f4d\u9a71\u52a8\u7801<\/p>\n

\n\tuchar code DispTab\uff3b\uff3d={0xC0\uff0c0xF9\uff0c0xA4\uff0c0xB0\uff0c0x99\uff0c0x92\uff0c0x82\uff0c0xF8\uff0c0x80\uff0c0x90\uff0c0x88\uff0c0x83\uff0c0xC6\uff0c0xA1\uff0c0x86\uff0c0x8E\uff0c0xFF};\u3000\/\/\u5b57\u5f62\u7801<\/p>\n

\n\tuchar DispBuf\uff3b6\uff3d; \/\/\u663e\u793a\u7f13\u51b2\u533a<\/p>\n

\n\tvoid Ti<\/u>mer1\uff08\uff09 inte<\/u>rrupt 3<\/p>\n

\n\t{ uchar tmp;<\/p>\n

\n\tuchar Count; \/\/\u8ba1\u6570\u5668\uff0c\u663e\u793a\u7a0b\u5e8f\u901a\u8fc7\u5b83\u5f97\u77e5\u73b0\u6b63\u663e\u793a\u54ea\u4e2a\u6570\u7801\u7ba1<\/p>\n

\n\tTH1=\uff0865536-3000\uff09\/256;<\/p>\n

\n\tTL1=\uff0865536-3000\uff09%256; \/\/\u91cd\u7f6e\u521d\u503c<\/p>\n

\n\ttmp=BitTab\uff3bCount\uff3d; \/\/\u53d6\u4f4d\u503c<\/p>\n

\n\tP2=P2|0xfc; \/\/P2\u4e0e11111100B\u76f8\u6216<\/p>\n

\n\tP2=P2&tmp; \/\/P2\u4e0e\u53d6\u51fa\u7684\u4f4d\u503c\u76f8\u4e0e<\/p>\n

\n\ttmp=DispBuf\uff3bCount\uff3d;\/\/\u53d6\u51fa\u5f85\u663e\u793a\u7684\u6570<\/p>\n

\n\ttmp=DispTab\uff3btmp\uff3d; \/\/\u53d6\u5b57\u5f62\u7801<\/p>\n

\n\tP0=tmp;<\/p>\n

\n\tCount++;<\/p>\n

\n\tif\uff08Count==6\uff09<\/p>\n

\n\tCount=0;<\/p>\n

\n\t}<\/p>\n

\n\tvoid mai<\/u>n\uff08\uff09<\/p>\n

\n\t{ uint tmp;<\/p>\n

\n\tP1=0xff;<\/p>\n

\n\tP0=0xff;<\/p>\n

\n\tTMOD=0x15; \/\/\u5b9a\u65f6\u5668<\/u>0\u5de5\u4f5c\u4e8e\u8ba1\u6570\u65b9\u5f0f1\uff0c\u5b9a\u65f6\u56681\u5de5\u4f5c\u4e8e\u5b9a\u65f6\u65b9\u5f0f1<\/p>\n

\n\tTH1=\uff0865536-3000\uff09\/256;<\/p>\n

\n\tTL1=\uff0865536-3000\uff09%256; \/\/\u5b9a\u65f6\u65f6\u95f4\u4e3a3000\u4e2a\u5468\u671f<\/p>\n

\n\tTR0=1; \/\/\u8ba1\u6570\u56680\u5f00\u59cb\u8fd0\u884c<\/p>\n

\n\tTR1=1;<\/p>\n

\n\tEA=1;<\/p>\n

\n\tET1=1;<\/p>\n

\n\tfor\uff08;;\uff09<\/p>\n

\n\t{ tmp=TL0|\uff08TH0\u300a\u300a8\uff09;\u3000\/\/\u53d6T0\u4e2d\u7684\u6570\u503c<\/p>\n

\n\tDispBuf\uff3b5\uff3d=tmp%10;<\/p>\n

\n\ttmp\/=10;<\/p>\n

\n\tDispBuf\uff3b4\uff3d=tmp%10;<\/p>\n

\n\ttmp\/=10;<\/p>\n

\n\tDispBuf\uff3b3\uff3d=tmp%10;<\/p>\n

\n\ttmp\/=10;<\/p>\n

\n\tDispBuf\uff3b2\uff3d=tmp%10;<\/p>\n

\n\tDispBuf\uff3b1\uff3d=tmp\/10;<\/p>\n

\n\tDispBuf\uff3b0\uff3d=0;<\/p>\n

\n\t}}<\/p>\n

\n\t\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\u7528\u5230\u4e86\u4e00\u4e2a\u65b0\u7684\u77e5\u8bc6\u70b9\uff0c\u5373\u6570\u7ec4\uff0c\u9996\u5148\u4f5c\u4e00\u4e2a\u4ecb\u7ecd\u3002<\/p>\n

\n\t\u6570\u7ec4\u662fC51\u7684\u4e00\u79cd\u6784\u9020\u6570\u636e\u7c7b\u578b\uff0c\u6570\u7ec4\u5fc5\u987b\u7531\u5177\u6709\u76f8\u540c\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u6784\u6210\uff0c\u8fd9\u4e9b\u6570\u636e\u7684\u7c7b\u578b\u5c31\u662f\u6570\u7ec4\u7684\u57fa\u672c\u7c7b\u578b\uff0c\u5982\uff1a\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u662f\u6574\u578b\uff0c\u5219\u8be5\u6570\u7ec4\u79f0\u4e3a\u6574\u578b\u6570\u7ec4\uff0c\u5982\u6240\u6709\u5143\u7d20\u90fd\u662f\u5b57\u7b26\u578b\uff0c\u5219\u8be5\u6570\u7ec4\u79f0\u4e3a\u5b57\u7b26\u578b\u6570\u7ec4\u3002<\/p>\n

\n\t\u6570\u7ec4\u5fc5\u987b\u8981\u5148\u5b9a\u4e49\uff0c\u540e\u4f7f\u7528\uff0c\u8fd9\u91cc\u4ec5\u4ecb\u7ecd\u4e00\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49\uff0c\u5176\u65b9\u5f0f\u4e3a\uff1a<\/p>\n

\n\t\u7c7b\u578b\u8bf4\u660e\u7b26\u3000\u6570\u7ec4\u540d\uff3b\u6574\u578b\u8868\u8fbe\u5f0f\uff3d<\/p>\n

\n\t\u5b9a\u4e49\u597d\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\uff1a\u6570\u7ec4\u540d\uff3b\u6574\u578b\u8868\u8fbe\u5f0f\uff3d\u6765\u4f7f\u7528\u6570\u7ec4\u5143\u7d20\u3002<\/p>\n

\n\t\u5728\u5b9a\u4e49\u6570\u7ec4\u65f6\uff0c\u53ef\u4ee5\u5bf9\u6570\u7ec4\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u5373\u7ed9\u5176\u8d4b\u4e88\u521d\u503c\uff0c\u8fd9\u53ef\u7528\u4ee5\u4e0b\u7684\u4e00\u4e9b\u65b9\u6cd5\u5b9e\u73b0\uff1a<\/p>\n

\n\t1\uff0e\u5728\u5b9a\u4e49\u6570\u7ec4\u65f6\u5bf9\u6570\u7ec4\u7684\u5168\u90e8\u5143\u7d20\u8d4b\u4e88\u521d\u503c\uff1a<\/p>\n

\n\t\u4f8b\uff1aint a\uff3b5\uff3d={1\uff0c2\uff0c3\uff0c4\uff0c5};<\/p>\n

\n\t2\uff0e\u53ea\u5bf9\u6570\u7ec4\u7684\u90e8\u5206\u5143\u7d20\u521d\u59cb\u5316\uff1b<\/p>\n

\n\t\u4f8b\uff1aint a\uff3b5\uff3d={1\uff0c2};<\/p>\n

\n\t\u4e0a\u9762\u5b9a\u4e49\u7684a\u6570\u7ec4\u5171\u67095\u4e2a\u5143\u7d20\uff0c\u4f46\u53ea\u5bf9\u524d\u4e24\u4e2a\u8d4b\u521d\u503c\uff0c\u56e0\u6b64a\uff3b0\uff3d\u548ca\uff3b1\uff3d\u7684\u503c\u662f1\u30012\uff0c\u800c\u540e\u97623\u4e2a\u5143\u7d20\u7684\u503c\u5168\u662f0\u3002<\/p>\n

\n\t3\uff0e\u5728\u5b9a\u4e49\u6570\u7ec4\u65f6\u5bf9\u6570\u7ec4\u5143\u7d20\u7684\u5168\u90e8\u5143\u7d20\u4e0d\u8d4b\u521d\u503c\uff0c\u5219\u6570\u7ec4\u5143\u7d20\u503c\u5747\u88ab\u521d\u59cb\u5316\u4e3a0<\/p>\n

\n\t4\uff0e\u53ef\u4ee5\u5728\u5b9a\u4e49\u65f6\u4e0d\u6307\u660e\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u800c\u6839\u636e\u8d4b\u503c\u90e8\u5206\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u786e\u5b9a<\/p>\n

\n\t\u4f8b\uff1auchar BitTab\uff3b\uff3d={0x7F\uff0c0xBF\uff0c0xDF\uff0c0xEF\uff0c0xF7\uff0c0xFB};\u5219\u76f8\u5f53\u4e8e\u5b9a\u4e49\u4e86\u4e00\u4e2aBitTab\uff3b6\uff3d\u8fd9\u6837\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n

\n\t5\uff0e\u53ef\u4ee5\u4e3a\u6570\u7ec4\u6307\u5b9a\u5b58\u50a8\u7a7a\u95f4\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u672a\u6307\u5b9a\u7a7a\u95f4\u65f6\uff0c\u5c06\u6570\u7ec4\u5b9a\u4e49\u5728\u5185\u90e8RAM<\/u>\u4e2d\uff0c\u53ef\u4ee5\u7528code\u5173\u952e\u5b57\u5c06\u6570\u7ec4\u5143\u7d20\u5b9a\u4e49\u5728ROM<\/u>\u7a7a\u95f4\u4e2d\u3002<\/p>\n

\n\tuchar code BitTab\uff3b\uff3d={0x7F\uff0c0xBF\uff0c0xDF\uff0c0xEF\uff0c0xF7\uff0c0xFB};<\/p>\n

\n\t\u7528\u8fd9\u4e24\u79cd\u5b9a\u4e49\u5206\u522b\u7f16\u8bd1\uff0c\u53ef\u4ee5\u770b\u51fa\u4f7f\u7528\u4e86code\u5173\u952e\u5b57\u540e\u7cfb\u7edf\u5360\u7528\u7684RAM\u6570\u51cf\u5c11\u4e86\uff0c\u8fd9\u79cd\u65b9\u5f0f\u7528\u4e8e\u7f16\u7a0b\u4e2d\u4e0d\u9700\u8981\u6539\u53d8\u5185\u5bb9\u7684\u573a\u5408\uff0c\u5982\u663e\u793a\u6570\u7801\u7ba1\u7684\u5b57\u5f62\u7801\u7b49\u662f\u5f88\u5408\u9002\u7684\u3002<\/p>\n

\n\t6\uff0eC\u8bed\u8a00\u5e76\u4e0d\u5bf9\u8d8a\u754c\u4f7f\u7528\u6570\u7ec4\u8fdb\u884c\u68c0\u6d4b\uff0c\u4f8b\u5982\u4e0a\u4f8b\u4e2d\u6570\u7ec4\u7684\u957f\u5ea6\u662f6\uff0c\u5176\u5143\u7d20\u5e94\u8be5\u662f\u4eceBitTab\uff3b0\uff3d~BitTab\uff3b5\uff3d\uff0c\u4f46\u662f\u5982\u679c\u4f60\u5728\u7a0b\u5e8f\u4e2d\u5199\u4e0a BitTab\uff3b6\uff3d\uff0c\u7f16\u8bd1\u5668\u5e76\u4e0d\u4f1a\u8ba4\u4e3a\u8fd9\u6709\u8bed\u6cd5\u9519\u8bef\uff0c\u4e5f\u4e0d\u4f1a\u7ed9\u51fa\u8b66\u544a\uff08\u5176\u4ed6\u8bed\u8a00\u5982BASCI\u7b49\u5219\u6709\u4e25\u683c\u7684\u89c4\u5b9a\uff0c\u8fd9\u79cd\u60c5\u51b5\u5c06\u89c6\u4e3a\u8bed\u6cd5\u9519\u8bef\uff09\uff0c\u56e0\u6b64\uff0c\u7f16\u7a0b\u8005\u5fc5 \u987b\u81ea\u5df1\u5c0f\u5fc3\u786e\u8ba4\u8fd9\u662f\u5426\u662f\u4f60\u9700\u8981\u7684\u7ed3\u679c\u3002<\/p>\n

\n\t\u7a0b\u5e8f\u5206\u6790\uff1a\u7a0b\u5e8f\u4e2d\u5c06\u5b9a\u65f6\u5668T1\u7528\u4f5c\u6570\u7801\u7ba1\u663e\u793a\uff0c\u901a\u8fc7interrupt 3\u5173\u952e\u5b57\u5b9a\u4e49\u51fd\u6570TImer1\uff08\uff09\u4e3a\u5b9a\u65f6\u56681\u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f\uff0c\u5728\u8fd9\u4e2a\u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528TH1=\uff0865536-3000\uff09\/256;<\/span><\/p>\n

\n\tTL1=\uff0865536-3000\uff09%256;<\/p>\n

\n\t\u6765\u91cd\u7f6e\u5b9a\u65f6\u5668\u521d\u503c\uff0c\u8fd9\u5176\u4e2d3000\u5373\u4e3a\u5b9a\u65f6\u5468\u671f\uff0c\u8fd9\u6837\u7684\u5199\u6cd5\u53ef\u4ee5\u76f4\u89c2\u5730\u770b\u5230\u5b9a\u65f6\u5468\u671f\u6570\uff0c\u662f\u5e38\u7528\u7684\u4e00\u79cd\u5199\u6cd5\u3002\u5176\u4f59\u7a0b\u5e8f\u6bb5\u5206\u522b\u5b8c\u6210\u53d6\u4f4d\u7801\u4ee5\u9009\u62e9\u6570\u7801\u7ba1\u3001\u4ece \u663e\u793a\u7f13\u51b2\u533a\u83b7\u5f97\u5f85\u663e\u793a\u6570\u503c\u3001\u6839\u636e\u8be5\u6570\u503c\u53d6\u6bb5\u7801\u4ee5\u70b9\u4eae\u76f8\u5e94\u7b14\u6bb5\u7b49\u4efb\u52a1\u3002\u5176\u4e2d\u4f7f\u7528\u4e86\u4e00\u4e2a\u8ba1\u6570\u5668\uff0c\u8be5\u8ba1\u6570\u5668\u7684\u503c\u4ece0~5\u5bf9\u5e94\u7b2c1\u5230\u7b2c6\u4f4d\u7684\u6570\u7801\u7ba1\u3002<\/p>\n

\n\t\u4e3b\u7a0b\u5e8f\u7684\u7b2c\u4e00\u90e8\u5206\u662f\u505a\u4e00\u4e9b\u521d\u59cb\u5316\u7684\u64cd\u4f5c\uff0c\u8bbe\u7f6e\u5b9a\u65f6\u5668\u5de5\u4f5c\u6a21\u5f0f\u3001\u5f00\u542f\u5b9a\u65f6\u5668T1\u3001\u5f00\u542f\u8ba1\u6570\u5668T0\u3001\u5f00\u542fT1\u4e2d\u65ad\u53ca\u603b\u4e2d\u65ad\uff0c\u968f\u540e\u8fdb\u5165\u4e3b\u5faa\u73af\uff0c\u4e3b\u5faa\u73af\u9996\u5148\u7528 unsigned int\u578b\u53d8\u91cftmp\u53d6\u51faT0\u4e2d\u7684\u6570\u503c\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86“tmp=TL0|\uff08TH0\u300a\u300a8\uff09;”\u8fd9\u6837\u7684\u5f62\u5f0f\uff0c\u8fd9\u76f8\u5f53\u4e8e tmp=TH0*256+TL0\uff0c\u4f46\u6bd4\u4e4b\u4e8e\u540e\u4e00\u79cd\u5f62\u5f0f\uff0c\u8be5\u65b9\u5f0f\u53ef\u4ee5\u5f97\u5230\u66f4\u9ad8\u7684\u6548\uff0c\u5176\u540e\u5c31\u662f\u5c06tmp\u503c\u4e0d\u65ad\u5730\u966410\u53d6\u6574\uff0c\u8fd9\u6837\u5c06int\u578b\u6570\u636e\u7684\u5404\u4f4d\u5206\u79bb\u5e76\u9001 \u5165\u76f8\u5e94\u7684\u663e\u793a .<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8be5\u90e8\u5206\u7684\u786c\u4ef6\u7535\u8def\u5982\u56fe\u6240\u793a\uff0cU1\u7684P0\u53e3\u548cP2\u53e3\u7684\u90e8\u4efd\u5f15\u811a\u6784\u6210\u4e866\u4f4dLED\u6570\u7801\u7ba1\u9a71\u52a8\u7535\u8def\uff0c\u6570\u7801\u7ba1\u91c7\u7528\u5171\u9633\u578b\uff0c\u4f7f\u7528PNP\u578b \u4e09\u6781\u7ba1 \u4f5c\u4e3a\u7247\u9009\u7aef\u7684\u9a71\u52a8\uff0c\u6240 \u6709\u4e09\u6781\u7ba1\u7684\u53d1\u5c04\u6781\u8fde\u5728\u4e00\u8d77\uff0c\u63a5\u5230\u6b63\u7535<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2106"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2106"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2106\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2106"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}