{"id":1057,"date":"2018-09-21T10:39:44","date_gmt":"2018-09-21T10:39:44","guid":{"rendered":""},"modified":"2018-09-21T18:40:06","modified_gmt":"2018-09-21T10:40:06","slug":"74hc138%e6%8e%a7%e5%88%b6%e5%85%b1%e9%98%b3%e6%95%b0%e7%a0%81%e7%ae%a1+74hc138%e9%a9%b1%e5%8a%a8%e5%85%b1%e9%98%b3%e6%95%b0%e7%a0%81%e7%ae%a1%e6%98%be%e7%a4%ba","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=1057","title":{"rendered":"74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1 74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u663e\u793a"},"content":{"rendered":"

\n\t74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u4f60\u4e86\u89e3\u591a\u5c11\u5462\uff1f74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u7684\u65b9\u5f0f\u662f\u4ec0\u4e48\u5462\uff1f\u672c\u6587\u4e3b\u8981\u5173\u4e8e74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u7684\u4ecb\u7ecd\u3002<\/p>\n

\n\t\u6570\u7801\u7ba1\u7684\u57fa\u672c\u4ecb\u7ecd<\/h2>\n

\n\t\"74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1<\/p>\n

\n\t\u6570\u7801\u7ba1\u539f\u7406\u56fe<\/p>\n

\n\t\u8fd9\u662f\u6bd4\u8f83\u5e38\u89c1\u7684\u6570\u7801\u7ba1\u7684\u539f\u7406\u56fe\uff0c\u6211\u4eec\u677f\u5b50\u4e0a\u4e00\u5171\u67096\u53ea\u6570\u7801\u7ba1\u3002\u524d\u8fb9\u6709\u4e86LED\u5c0f\u706f\u7684\u5b66\u4e60\uff0c\u6570\u7801\u7ba1\u5b66\u4e60\u5c31\u4f1a\u8f7b\u677e\u7684\u591a\u4e86\u3002\u4ece\u56fe1\u80fd\u770b\u51fa\u6765\uff0c\u6570\u7801\u7ba1\u5171\u6709a,b,c,d,e,f,g,dp\u8fd98\u4e2a\u6bb5\uff0c\u800c\u5b9e\u9645\u4e0a\uff0c\u8fd98\u4e2a\u6bb5\u6bcf\u4e00\u6bb5\u90fd\u662f\u4e00\u4e2aLED\u5c0f\u706f\uff0c\u6240\u4ee5\u6570\u7801\u7ba1\u5c31\u662f\u75318\u4e2aLED\u5c0f\u706f\u6240\u7ec4\u6210\u7684\u3002\u6211\u4eec\u770b\u4e00\u4e0b\u6570\u7801\u7ba1\u5185\u90e8\u7ed3\u6784\u56fe\u3002<\/p>\n

\n\t\"74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1<\/p>\n

\n\t\u6570\u7801\u7ba1\u5206\u4e3a\u5171\u9633\u6570\u7801\u7ba1\u548c\u5171\u9634\u6570\u7801\u7ba1\uff0c\u6240\u8c13\u7684\u5171\u9634\u6570\u7801\u7ba1\u5c31\u662f8\u53eaLED\u5c0f\u706f\u7684\u9634\u6781\u662f\u63a5\u5728\u4e00\u8d77\u7684\uff0c\u4e5f\u5c31\u662f\u9634\u6781\u662f\u516c\u5171\u7aef\uff0c\u7531\u9633\u6781\u6765\u63a7\u5236\u5c0f\u706f\u662f\u5426\u4eae\u706d\u3002\u540c\u7406\uff0c\u5171\u9633\u6570\u7801\u7ba1\u5c31\u662f\u9633\u6781\u662f\u63a5\u5230\u4e00\u8d77\u7684\uff0c\u5927\u5bb6\u53ef\u4ee5\u4ed4\u7ec6\u7814\u7a76\u4e0b\u56fe1\u3002\u7ec6\u5fc3\u7684\u540c\u5b66\u4e5f\u4f1a\u53d1\u73b0\uff0c\u6570\u7801\u7ba1\u4e0a\u8fb9\u67092\u4e2acom\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u6211\u4eec\u6570\u7801\u7ba1\u7684\u516c\u5171\u7aef\u3002\u4e3a\u4ec0\u4e48\u67092\u4e2a\uff0c\u6211\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u4e00\u65b9\u9762\u67092\u4e2a\u53ef\u4ee5\u8d77\u5230\u5bf9\u79f0\u7684\u6548\u679c\uff0c\u521a\u597d\u662f10\u4e2a\u5f15\u811a\uff0c\u53e6\u5916\u4e00\u4e2a\u65b9\u9762\uff0c\u516c\u5171\u7aef\u901a\u8fc7\u7684\u7535\u6d41\u8f83\u5927\uff0c\u6211\u4eec\u521d\u4e2d\u5c31\u5b66\u8fc7\uff0c\u5e76\u8054\u7535\u8def\u7535\u6d41\u4e4b\u548c\u7b49\u4e8e\u603b\u7535\u6d41\uff0c\u75282\u4e2acom\u53ef\u4ee5\u628a\u516c\u5171\u7535\u6d41\u5e73\u5747\u52302\u4e2a\u5f15\u811a\u4e0a\u53bb\uff0c\u964d\u4f4e\u7ebf\u8def\u627f\u53d7\u7684\u7535\u6d41\u3002<\/p>\n

\n\t\u4ece\u6211\u4eec\u677f\u5b50\u7684\u7535\u8def\u56fe\u4e0a\u80fd\u770b\u51fa\u6765\uff0c\u6211\u4eec\u6240\u7528\u7684\u6570\u7801\u7ba1\u662f\u5171\u9633\u6570\u7801\u7ba1\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n

\n\t\"74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1<\/p>\n

\n\t\u5171\u9633\u6570\u7801\u7ba1\u7535\u8def<\/p>\n

\n\t74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1<\/h2>\n

\n\t\u4ece\u4e0a\u6587\u6211\u4eec\u77e5\u9053\uff0c\u4ed6\u4eec\u7684com\u662f\u63a5\u5230\u4e86\u6b63\u6781\u4e0a\uff0c\u5f53\u7136\u4e86\uff0c\u548cLED\u5c0f\u706f\u7535\u8def\u7c7b\u4f3c\uff0c\u4e5f\u662f\u753174HC138\u63a7\u5236\u4e86\u4e09\u6781\u7ba1\u7684\u5bfc\u901a\u6765\u63a7\u5236\u6574\u4e2a\u6570\u7801\u7ba1\u7684\u7535\u6d41\uff0c\u6211\u4eec\u5148\u6765\u770bDS1\u8fd9\u4e2a\u6570\u7801\u7ba1\u3002\u539f\u7406\u56fe\u4e0a\u53ef\u4ee5\u770b\u51fa\u6765\uff0c\u63a7\u5236DS1\u7684\u4e09\u6781\u7ba1\u662fQ17\uff0c\u63a7\u5236Q17\u7684\u5f15\u811a\u662fLEDS0\uff0c\u5bf9\u5e94\u523074HC138\u4e0a\u8fb9\u5c31\u662fY0\u7aef\u7684\u8f93\u51fa\u3002<\/p>\n

\n\t\"74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1<\/p>\n

\n\t74HC138\u63a7\u5236\u56fe<\/p>\n

\n\t\u6211\u4eec\u73b0\u5728\u7684\u76ee\u7684\u662f\u8ba9LEDS0\u8fd9\u4e2a\u5f15\u811a\u8f93\u51fa\u4f4e\u7535\u5e73\uff0c\u76f8\u4fe1\u5927\u5bb6\u73b0\u5728\u53ef\u4ee5\u72ec\u7acb\u6839\u636e\u524d\u8fb9\u5b66\u5230\u7684\u5185\u5bb9\u628aADDR0\uff0cADDR1\uff0cADDR2\uff0cADDR3\uff0cENLED\u8fd94\u4e2a\u8f93\u5165\u72b6\u6001\u5199\u51fa\u6765\uff0c\u73b0\u5728\u5927\u5bb6\u4e0d\u8981\u5077\u61d2\uff0c\u90fd\u53bb\u6839\u636e138\u7684\u624b\u518c\u53bb\u5199\u4e00\u4e0b\uff0c\u4e0d\u9700\u8981\u4f60\u8bb0\u4f4f\u8fd9\u4e9b\u7ed3\u8bba\uff0c\u4f46\u662f\u9047\u5230\u5c31\u5199\u4e00\u6b21\uff0c\u953b\u70bc\u8fc7\u51e0\u6b21\u540e\uff0c\u9047\u5230\u540c\u7c7b\u82af\u7247\u81ea\u5df1\u5c31\u77e5\u9053\u5982\u4f55\u53bb\u89e3\u51b3\u95ee\u9898\u4e86\u3002<\/p>\n

\n\t\u6570\u7801\u7ba1\u901a\u5e38\u662f\u7528\u6765\u663e\u793a\u6570\u5b57\u7684\uff0c\u6211\u4eec\u677f\u5b50\u4e0a\u76846\u4e2a\u6570\u7801\u7ba1\uff0c\u4e60\u60ef\u4e0a\u6211\u4eec\u79f0\u4e4b\u4e3a6\u4f4d\uff0c\u90a3\u63a7\u5236\u4f4d\u9009\u62e9\u7684\u5c31\u662f74HC138\u4e86\u3002\u800c\u6570\u7801\u7ba1\u5185\u90e8\u76848\u4e2aLED\u5c0f\u706f\u6211\u4eec\u79f0\u4e4b\u4e3a\u6570\u7801\u7ba1\u7684\u6bb5\uff0c\u90a3\u4e48\u6570\u7801\u7ba1\u7684\u6bb5\u9009\u62e9\uff08\u5373\u8be5\u6bb5\u7684\u4eae\u706d\uff09\u662f\u901a\u8fc7P0\u53e3\u63a7\u5236\uff0c\u7ecf\u8fc774HC245\u9a71\u52a8\uff0c\u8fd9\u6837\u6574\u4e2a\u7535\u8def\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n

\n\t74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1\u7a0b\u5e8f<\/strong><\/p>\n

\n\t#include \/\/\u5305\u542b\u5bc4\u5b58\u5668<\/u>\u7684\u5e93\u6587\u4ef6<\/p>\n

\n\tsbit ADDR0 = P1^0;<\/p>\n

\n\tsbit ADDR1 = P1^1;<\/p>\n

\n\tsbit ADDR2 = P1^2;<\/p>\n

\n\tsbit ADDR3 = P1^3;<\/p>\n

\n\tsbit ENLED = P1^4;<\/p>\n

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

\n\t{<\/p>\n

\n\tunsigned char j = 0;<\/p>\n

\n\tunsigned int i = 0;<\/p>\n

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

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

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

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

\n\tADDR3 = 1; \/\/74HC138\u5f00\u542f\u4e09\u6781\u7ba1Q17<\/p>\n

\n\twhile\uff081\uff09 \/\/\u7a0b\u5e8f\u6b7b\u5faa\u73af<\/p>\n

\n\t{<\/p>\n

\n\tP0 = 0xF9; \/\/\u6253\u5f00\u6570\u7801\u7ba1b\u548cc\u6bb5<\/p>\n

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

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

\n\t\u6570\u7801\u7ba1\u7684\u9759\u6001\u663e\u793a<\/h2>\n

\n\t\u4ece\u4e0a\u6587\u6211\u4eec\u4e86\u89e3\u523074HC138\u540c\u65f6\u4e00\u6b21\u53ea\u80fd\u8ba9\u4e00\u4e2a\u8f93\u51fa\u53e3\u4e3a\u4f4e\u7535\u5e73\uff0c\u4e5f\u5c31\u662f\u5728\u4e00\u4e2a\u65f6\u523b\u5185\uff0c\u6211\u4eec\u53ea\u80fd\u8ba9\u4e00\u4e2a\u6570\u7801\u7ba1\u663e\u793a\uff0c\u59cb\u7ec8\u9009\u901a\u6570\u7801\u7ba1\u5e76\u4e14\u53ef\u4ee5\u6839\u636e\u6211\u4eec\u7684P0\u603b\u7ebf\u7684\u4fe1\u53f7\u6765\u6539\u53d8\u8fd9\u4e2a\u6570\u7801\u7ba1\u7684\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u7406\u89e3\u4e3a\u6570\u7801\u7ba1\u7684\u9759\u6001\u663e\u793a\u3002<\/p>\n

\n\t\u6570\u7801\u7ba1\u9759\u6001\u663e\u793a\u662f\u5bf9\u5e94\u52a8\u6001\u663e\u793a\u800c\u8a00\u7684\uff0c\u9759\u6001\u663e\u793a\u5bf9\u4e8e\u4e00\u4e24\u4e2a\u6570\u7801\u7ba1\u8fd8\u884c\uff0c\u591a\u4e2a\u6570\u7801\u7ba1\uff0c\u9759\u6001\u663e\u793a\u5b9e\u73b0\u7684\u610f\u4e49\u5c31\u6ca1\u6709\u4e86\u3002\u8fd9\u8282\u8bfe\u6211\u4eec\u5148\u7528\u4e00\u4e2a\u6570\u7801\u7ba1\u7684\u9759\u6001\u663e\u793a\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u79d2\u8868\uff0c\u4e3a\u4e0b\u8282\u8bfe\u7684\u52a8\u6001\u663e\u793a\u6253\u4e0b\u57fa\u7840\u3002<\/p>\n

\n\t\u5148\u6765\u4ecb\u7ecd\u4e00\u4e2a51\u5355\u7247\u673a<\/u>\u7684\u5173\u952e\u5b57code\u3002\u6211\u4eec\u524d\u8fb9\u8bfe\u7a0b\u5b9a\u4e49\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u4e00\u822c\u7528\u5230unsigned char\u6216\u8005unsigned int\u8fd9\u4e24\u4e2a\u5173\u952e\u5b57\uff0c\u8fd9\u6837\u5b9a\u4e49\u7684\u53d8\u91cf\u90fd\u662f\u653e\u5728\u6211\u4eec\u7684\u5355\u7247\u673a\u7684RAM<\/u>\u4e2d\uff0c\u6211\u4eec\u5728\u7a0b\u5e8f\u4e2d\u53ef\u4ee5\u968f\u610f\u53bb\u6539\u53d8\u8fd9\u4e2a\u53d8\u91cf\u7684\u503c\u3002\u4f46\u662f\u8fd8\u6709\u4e00\u79cd\u5e38\u6570\uff0c\u6211\u4eec\u5728\u7a0b\u5e8f\u4e2d\u8981\u4f7f\u7528\uff0c\u4f46\u662f\u5374\u4e0d\u8fdb\u884c\u5bf9\u8fd9\u4e2a\u503c\u7684\u6539\u53d8\uff0c\u8fd9\u79cd\u503c\u6211\u4eec\u53ef\u4ee5\u52a0\u4e00\u4e2acode\u5173\u952e\u5b57\u4fee\u9970\u4e00\u4e0b\uff0c\u4fee\u9970\u5b8c\u6bd5\u540e\uff0c\u8fd9\u4e2a\u503c\u5c31\u4f1a\u5b58\u50a8\u5230\u6211\u4eec\u7684\u7a0b\u5e8f\u7a7a\u95f4flash\u4e2d\uff0c\u8fd9\u6837\u53ef\u4ee5\u5927\u5927\u8282\u7701\u6211\u4eec\u5355\u7247\u673a\u7684RAM\u7684\u4f7f\u7528\u91cf\uff0c\u6bd5\u7adf\u6211\u4eec\u7684RAM\u7a7a\u95f4\u6bd4\u8f83\u5c0f\uff0c\u800c\u7a0b\u5e8f\u7a7a\u95f4\u662f\u5f88\u5927\u7684\u3002<\/p>\n

\n\t\u6570\u7801\u7ba1\u7684\u9759\u6001\u663e\u793a\u7a0b\u5e8f\uff1a<\/strong><\/p>\n

\n\t#include \/\/\u5305\u542b\u5bc4\u5b58\u5668\u7684\u5e93\u6587\u4ef6<\/p>\n

\n\tsbit LED = P0^0;<\/p>\n

\n\tsbit ADDR0 = P1^0;<\/p>\n

\n\tsbit ADDR1 = P1^1;<\/p>\n

\n\tsbit ADDR2 = P1^2;<\/p>\n

\n\tsbit ADDR3 = P1^3;<\/p>\n

\n\tsbit ENLED = P1^4;<\/p>\n

\n\tunsigned char code LedChar\uff3b\uff3d = {<\/p>\n

\n\t0xC0\uff0c0xF9\uff0c0xA4\uff0c0xB0\uff0c0x99\uff0c0x92\uff0c0x82\uff0c0xF8\uff0c<\/p>\n

\n\t0x80\uff0c0x90\uff0c0x88\uff0c0x83\uff0c0xC6\uff0c0xA1\uff0c0x86\uff0c0x8e<\/p>\n

\n\t}; \/\/\u7528\u6570\u7ec4\u6765\u5b58\u50a8\u6570\u7801\u7ba1\u771f\u503c\u8868\uff0c\u4e0b\u4e00\u8bfe\u8be6\u7ec6\u4ecb\u7ecd\u6570\u7ec4<\/p>\n

\n\tvoid main\uff08\uff09<\/p>\n

\n\t{<\/p>\n

\n\tunsigned char counte<\/u>r = 0;<\/p>\n

\n\tunsigned char j = 0;<\/p>\n

\n\tENLED = 0; ADDR0 = 0; ADDR1 = 0;<\/p>\n

\n\tADDR2 = 0; ADDR3 = 1; P0 = 0XFF; \/\/74HC138\u548cP0\u521d\u59cb\u5316\u90e8\u5206<\/p>\n

\n\tTMOD = 0x01; \/\/\u8bbe\u7f6e\u5b9a\u65f6\u5668<\/u>0\u4e3a\u6a21\u5f0f1<\/p>\n

\n\tTH0 = 0xB8;<\/p>\n

\n\tTL0 = 0x00; \/\/\u5b9a\u65f6\u503c\u521d\u503c<\/p>\n

\n\tTR0 = 1; \/\/\u6253\u5f00\u5b9a\u65f6\u56680<\/p>\n

\n\twhile\uff081\uff09<\/p>\n

\n\t{<\/p>\n

\n\tif\uff081 == TF0\uff09 \/\/\u5224\u65ad\u5b9a\u65f6\u56680\u662f\u5426\u6ea2\u51fa<\/p>\n

\n\t{<\/p>\n

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

\n\tTH0 = 0xB8; \/\/\u6ea2\u51fa\u540e\uff0c\u91cd\u65b0\u8d4b\u503c<\/p>\n

\n\tTL0 = 0x00;<\/p>\n

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

\n\tif\uff0850 == counter\uff09 \/\/\u5224\u65ad\u5b9a\u65f6\u56680\u6ea2\u51fa\u662f\u5426\u8fbe\u523050\u6b21<\/p>\n

\n\t{<\/p>\n

\n\tcounter = 0; \/\/counter\u6e050\uff0c\u91cd\u65b0\u8ba1\u6570<\/p>\n

\n\tP0 = LedChar\uff3bj++\uff3d; \/\/\u628a\u6570\u7ec4\u91cc\u7684\u5bf9\u5e94\u503c\u9001\u7ed9P0<\/p>\n

\n\tif\uff0816 == j\uff09 \/\/\u5f53\u663e\u793a\u5230F\u540e\uff0c\u5f520\u91cd\u65b0\u5f00\u59cb<\/p>\n

\n\t{<\/p>\n

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

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

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

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

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

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

\n\t\u7ed3\u8bed<\/h2>\n

\n\t\u5173\u4e8e74hc138\u63a7\u5236\u5171\u9633\u6570\u7801\u7ba1\u7684\u4ecb\u7ecd\u5c31\u5230\u8fd9\u91cc\u4e86\uff0c\u5982\u6709\u4e0d\u8db3\u4e4b\u5904\u6b22\u8fce\u6307\u6b63\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u4f60\u4e86\u89e3\u591a\u5c11\u5462\uff1f74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u7684\u65b9\u5f0f\u662f\u4ec0\u4e48\u5462\uff1f\u672c\u6587\u4e3b\u8981\u5173\u4e8e74hc138\u9a71\u52a8\u5171\u9633\u6570\u7801\u7ba1\u7684\u4ecb\u7ecd\u3002 \u6570\u7801\u7ba1\u7684\u57fa\u672c\u4ecb\u7ecd \u6570\u7801\u7ba1\u539f\u7406\u56fe \u8fd9\u662f\u6bd4\u8f83\u5e38\u89c1\u7684\u6570\u7801\u7ba1\u7684\u539f\u7406<\/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\/1057"}],"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=1057"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/1057\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}