{"id":2489,"date":"2019-05-25T03:18:38","date_gmt":"2019-05-25T03:18:38","guid":{"rendered":""},"modified":"2019-05-25T11:19:02","modified_gmt":"2019-05-25T03:19:02","slug":"at89c52%e5%8d%95%e7%89%87%e6%9c%ba%e5%af%b9%e5%85%ab%e8%b7%af%e7%94%b5%e5%8e%8b%e8%a1%a8%e7%9a%84%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2489","title":{"rendered":"AT89C52\u5355\u7247\u673a\u5bf9\u516b\u8def\u7535\u538b\u8868\u7684\u8bbe\u8ba1"},"content":{"rendered":"
\n\t\u516b\u8def\u7535\u538b\u8868C\u7a0b\u5e8f<\/p>\n
\n\t\/*\u4f7f\u7528AT89C52\u5355\u7247\u673a<\/u>\uff0c12MHz\u6676\u632f\uff0cP0\u53e3\u8bfb\u5165AD\u503c\uff0cP2\u53e3\u4f5cAD\u63a7\u5236\uff0c\u7528\u5171\u9633LED\u6570\u7801\u7ba1<\/p>\n \n\tP1\u53e3\u8f93\u51fa\u6bb5\u7801\uff0cP3\u53e3\u626b\u63cf\uff0c\u6700\u9ad8\u4f4d\u6307\u793a\u901a\u9053\uff080-7\uff09\u3002*\/<\/p>\n \n\t#include“reg52.h”\/\/52\u7cfb\u5217\u5355\u7247\u673a\u5b9a\u4e49\u6587\u4ef6<\/p>\n \n\t#include“intrins.h”\/\/\u8c03\u7528_nop_\uff08\uff09;\u5ef6\u65f6\u51fd\u6570\u7528<\/p>\n \n\t#definead_conP2\/\/AD\u63a7\u5236\u53e3<\/p>\n \n\t#defineaddataP0\/\/AD\u6570\u636e\u8ba1\u5165\u8bfb\u5165\u53e3<\/p>\n \n\t#defineDisdataP1\/\/\u663e\u793a\u6570\u636e\u6bb5\u7801\u8f93\u51fa\u53e3<\/p>\n \n\t#defineucharunsignedchar\/\/\u65e0\u7b26\u53f7\u5b57\u7b26<\/u>\uff088\u4f4d\uff09<\/p>\n \n\t#defineuintunsignedint\/\/\u65e0\u7b26\u53f7\u6574\u6570\uff0816\u4f4d\uff09<\/p>\n \n\tsbitALE=P2^3;\/\/\u9501<\/u>\u5b58\u5730\u5740\u63a7\u5236\u4f4d<\/p>\n \n\tsbitSTART=P2^4;\/\/\u542f\u52a8\u4e00\u6b21\u8f6c\u6362\u4f4d<\/p>\n \n\tsbitOE=P2^5;\/\/0809\u8f93\u51fa\u6570\u636e\u63a7\u5236\u4f4d<\/p>\n \n\tsbitE<\/u>OC=P3^7;\/\/\u8f6c\u6362\u7ed3\u675f\u6807\u5fd7\u4f4d<\/p>\n \n\tsbitDISX=Disdata^7;\/\/LED\u5c0f\u6570\u70b9<\/p>\n \n\t<\/p>\n \n\tucharcodedis_7\uff3b11\uff3d={0xC0\uff0c0xF9\uff0c0xA4\uff0c0xB0\uff0c0x99\uff0c0x92\uff0c0x82\uff0c0xF8\uff0c0x80\uff0c0x90\uff0c0xff};<\/p>\n \n\t\/*\u5171\u9633\u4e03\u6bb5LED\u6bb5\u7801\u8868“0”“1”“2”“3”“4”“5”“6”“7”“8”“9”“\u4e0d\u4eae”*\/<\/p>\n \n\tucharcodesCAN<\/u>_con\uff3b4\uff3d={0xfe\uff0c0xfd\uff0c0xfb\uff0c0xf7};\/\/\u56db\u4f4d\u5217\u626b\u63cf\u63a7\u5236\u5b57<\/p>\n \n\tuchardataad_data\uff3b8\uff3d={0x00\uff0c0x00\uff0c0x00\uff0c0x00\uff0c0x00\uff0c0x00\uff0c0x00\uff0c0x00};\/\/\u5b9a\u4e498\u4e2a\u6570\u636e\u5185\u5b58\u5355\u5143<\/p>\n \n\tuintdatadi<\/u>s\uff3b5\uff3d={0x00\uff0c0x00\uff0c0x00\uff0c0x00\uff0c0x00};\/\/\u5b9a\u4e494\u4e2a\u663e\u793a\u6570\u636e\u5355\u5143\u30011\u4e2a\u6570\u636e\u6682\u5b58\u5355\u5143<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/<\/p>\n \n\t\/********1\u6beb\u79d2\u5ef6\u65f6\u5b50\u51fd\u6570**********\/<\/p>\n \n\tdelay1ms\uff08uintt\uff09<\/p>\n \n\t{<\/p>\n \n\tuinti<\/u>\uff0cj;<\/p>\n \n\tfor\uff08i=0;ifor\uff08j=0;j\u300a120;j++\uff09<\/p>\n \n\t;<\/p>\n \n\t}<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/<\/p>\n \n\t\/***********\u663e\u793a\u626b\u63cf\u5b50\u51fd\u6570**********\/<\/p>\n \n\tscan\uff08\uff09<\/p>\n \n\t{<\/p>\n \n\tuchark\uff0cn;<\/p>\n \n\tinth;<\/p>\n \n\tdis\uff3b3\uff3d=0x00;\/\/\u901a\u9053\u521d\u503c\u4e3a0<\/p>\n \n\tfor\uff08n=0;n\u300a8;n++\uff09\/\/\u6bcf\u6b21\u663e\u793a8\u4e2a\u6570\u636e<\/p>\n \n\t{<\/p>\n \n\tdis\uff3b2\uff3d=ad_data\uff3bn\uff3d\/51;\/\/\u6d4b\u5f97\u503c\u8f6c\u6362\u4e3a\u4e09\u4f4dBCD\u7801\uff0c\u6700\u5927\u4e3a5.00V<\/p>\n \n\tdis\uff3b4\uff3d=ad_data\uff3bn\uff3d%51;\/\/\u4f59\u6570\u6682\u5b58<\/p>\n \n\tdis\uff3b4\uff3d=dis\uff3b4\uff3d*10;\/\/\u8ba1\u7b97\u5c0f\u6570\u7b2c\u4e00\u4f4d<\/p>\n \n\tdis\uff3b1\uff3d=dis\uff3b4\uff3d\/51;\/\/<\/p>\n \n\tdis\uff3b4\uff3d=dis\uff3b4\uff3d%51;\/\/<\/p>\n \n\tdis\uff3b4\uff3d=dis\uff3b4\uff3d*10;\/\/\u8ba1\u7b97\u5c0f\u6570\u7b2c\u4e8c\u4f4d<\/p>\n \n\tdis\uff3b0\uff3d=dis\uff3b4\uff3d\/51;\/\/<\/p>\n \n\tfor\uff08h=0;h\u300a500;h++\uff09\/\/\u6bcf\u4e2a\u901a\u9053\u503c\u663e\u793a\u65f6\u95f4\u63a7\u5236\uff08\u7ea61\u79d2\uff09<\/p>\n \n\t{<\/p>\n \n\tfor\uff08k=0;k\u300a4;k++\uff09\/\/\u56db\u4f4dLED\u626b\u63cf\u63a7\u5236<\/p>\n \n\t{<\/p>\n \n\tDisdata=dis_7\uff3bdis\uff3bk\uff3d\uff3d;<\/p>\n \n\tif\uff08k==2\uff09{DISX=0;}<\/p>\n \n\tP3=scan_con\uff3bk\uff3d;delay1ms\uff081\uff09;P3=0xff;<\/p>\n \n\t}<\/p>\n \n\t}<\/p>\n \n\tdis\uff3b3\uff3d++;\/\/\u901a\u9053\u503c\u52a01<\/p>\n \n\t}<\/p>\n \n\t}<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/<\/p>\n \n\t\/*******0809AD\u8f6c\u6362\u5b50\u51fd\u6570***********\/<\/p>\n \n\ttest\uff08\uff09<\/p>\n \n\t{<\/p>\n \n\tucharm<\/u>;<\/p>\n \n\tuchars<\/u>=0x00;<\/p>\n \n\tad_con=s;<\/p>\n \n\tfor\uff08m=0;m\u300a8;m++\uff09<\/p>\n \n\t{<\/p>\n \n\tALE=1;_nop_\uff08\uff09;_nop_\uff08\uff09;ALE=0;\/\/\u8f6c\u6362\u901a\u9053\u5730\u5740\u9501\u5b58<\/p>\n \n\tSTART=1;_nop_\uff08\uff09;_nop_\uff08\uff09;START=0;\/\/\u5f00\u59cb\u8f6c\u6362\u547d\u4ee4<\/p>\n \n\t_nop_\uff08\uff09;_nop_\uff08\uff09;_nop_\uff08\uff09;_nop_\uff08\uff09;\/\/\u5ef6\u65f64\u5fae\u79d2<\/p>\n \n\twhile\uff08EOC==0\uff09;\/\/\u7b49\u5f85\u8f6c\u6362\u7ed3\u675f<\/p>\n \n\tOE=1;ad_data\uff3bm\uff3d=addata;OE=0;s++;ad_con=s;\/\/\u53d6AD\u503c\uff0c\u5730\u5740\u52a01<\/p>\n \n\t}<\/p>\n \n\tad_con=0x00;\/\/\u63a7\u5236\u590d\u4f4d<\/p>\n \n\t}<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/<\/p>\n \n\t\/**************\u4e3b\u51fd\u6570****************\/<\/p>\n \n\tmai<\/u>n\uff08\uff09<\/p>\n \n\t{<\/p>\n \n\tP0=0xff;\/\/\u521d\u59cb\u5316\u7aef\u53e3<\/p>\n \n\tP2=0x00;<\/p>\n \n\tP1=0xff;<\/p>\n \n\tP3=0xff;<\/p>\n \n\twhile\uff081\uff09<\/p>\n \n\t{<\/p>\n \n\tscan\uff08\uff09;\/\/\u4f9d\u6b21\u663e\u793a8\u4e2a\u901a\u9053\u503c\u4e00\u6b21<\/p>\n \n\ttest\uff08\uff09;\/\/\u6d4b\u91cf\u8f6c\u6362\u4e00\u6b21<\/p>\n \n\t}<\/p>\n \n\t}<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/<\/p>\n \n\t\/\/*********************\u7ed3\u675f**************************\/\/<\/p>\n","protected":false},"excerpt":{"rendered":" \u516b\u8def\u7535\u538b\u8868C\u7a0b\u5e8f \/*\u4f7f\u7528AT89C52 \u5355\u7247\u673a \uff0c12MHz\u6676\u632f\uff0cP0\u53e3\u8bfb\u5165AD\u503c\uff0cP2\u53e3\u4f5cAD\u63a7\u5236\uff0c\u7528\u5171\u9633LED\u6570\u7801\u7ba1 P1\u53e3\u8f93\u51fa\u6bb5\u7801\uff0cP3\u53e3\u626b\u63cf\uff0c\u6700\u9ad8\u4f4d\u6307\u793a\u901a\u9053\uff080-7\uff09\u3002*\/ #includereg52.h\/\/52\u7cfb\u5217\u5355\u7247\u673a\u5b9a\u4e49\u6587\u4ef6<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2489"}],"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=2489"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2489\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2489"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}