﻿{"id":315,"date":"2021-01-14T21:15:54","date_gmt":"2021-01-14T13:15:54","guid":{"rendered":"https:\/\/dt9025a.xyz\/?p=315"},"modified":"2021-11-21T13:38:37","modified_gmt":"2021-11-21T05:38:37","slug":"stc8g1k08a-pca_pwm%e5%af%84%e5%ad%98%e5%99%a8%e6%93%8d%e4%bd%9c%e8%b8%a9%e5%9d%91","status":"publish","type":"post","link":"https:\/\/dt9025a.top\/?p=315","title":{"rendered":"STC8G1K08A-PCA_PWM\u5bc4\u5b58\u5668\u64cd\u4f5c\u8e29\u5751"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">01 \u524d\u8a00<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"98\" src=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-4-1024x98.png\" alt=\"\" class=\"wp-image-316\" srcset=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-4-1024x98.png 1024w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-4-300x29.png 300w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-4-768x73.png 768w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-4.png 1248w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u5c31\u662f\u8fd9\u4e9b\u4e2a\u5bc4\u5b58\u5668<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u53d1\u751f\u4e86\u751a\u4e48\u4e8b\u5462\uff1f<\/p>\n\n\n\n<p>\u4e8b\u60c5\u662f\u8fd9\u6837\u7684\uff0c\u9879\u76ee\u9700\u8981\u7528\u5230PWM\uff0c\u5f88\u5feb\u554a\uff0c\u6211\u5c31\u60f3\u5230\u4e86\u6211\u4eec\u5389\u5bb3\u7684STC\u3002<\/p>\n\n\n\n<p>\u6253\u5f00STC-ISP\u5f00\u59cb\u9009\u578b\uff0c\u5f88\u5feb\u554a\uff0c\u627e\u5230\u624b\u5934\u6709\u7684STC8G1K08A\u7b26\u5408\u8981\u6c42\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6ce8\uff1a\u300a\u624b\u518c\u300b\u4e3a2020-11-05\u7248STC8G\u8bf4\u660e\u624b\u518c<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">02 \u53d1\u5c55<\/h3>\n\n\n\n<p>\u76f4\u63a5\u590d\u5236\u7c98\u8d34\u4f8b\u7a0b\uff0c\u4e00\u6c14\u5475\u6210\uff0c\u7f16\u8bd1\u4e0b\u8f7d\uff0cPWM\u6b63\u5e38\u8f93\u51fa\u4f8b\u7a0b\u4e2d\u7684\u5360\u7a7a\u6bd4\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u7684\u4f8b\u7a0b\u5982\u4e0b\uff0c\u4f4d\u4e8e\u300a\u624b\u518c\u300b\u7684552\u4e0e553\u9875\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/\u6d4b\u8bd5\u5de5\u4f5c\u9891\u7387\u4e3a11.0592MHz\n#include \"reg51.h\"\n#include \"intrins.h\"\nsfr CCON = 0xd8;\nsbit CF = CCON ^ 7;\nsbit CR = CCON ^ 6;\nsbit CCF2 = CCON ^ 2;\nsbit CCF1 = CCON ^ 1;\nsbit CCF0 = CCON ^ 0;\nsfr CMOD = 0xd9;\nsfr CL = 0xe9;\nsfr CH = 0xf9;\nsfr CCAPM0 = 0xda;\nsfr CCAP0L = 0xea;\nsfr CCAP0H = 0xfa;\nsfr PCA_PWM0 = 0xf2;\nsfr CCAPM1 = 0xdb;\nsfr CCAP1L = 0xeb;\nsfr CCAP1H = 0xfb;\nsfr PCA_PWM1 = 0xf3;\nsfr CCAPM2 = 0xdc;\nsfr CCAP2L = 0xec;\nsfr CCAP2H = 0xfc;\nsfr PCA_PWM2 = 0xf4;\nsfr P0M1 = 0x93;\nsfr P0M0 = 0x94;\nsfr P1M1 = 0x91;\nsfr P1M0 = 0x92;\nsfr P2M1 = 0x95;\nsfr P2M0 = 0x96;\nsfr P3M1 = 0xb1;\nsfr P3M0 = 0xb2;\nsfr P4M1 = 0xb3;\nsfr P4M0 = 0xb4;\nsfr P5M1 = 0xc9;\nsfr P5M0 = 0xca;\nvoid main()\n{\n    P0M0 = 0x00;\n    P0M1 = 0x00;\n    P1M0 = 0x00;\n    P1M1 = 0x00;\n    P2M0 = 0x00;\n    P2M1 = 0x00;\n    P3M0 = 0x00;\n    P3M1 = 0x00;\n    P4M0 = 0x00;\n    P4M1 = 0x00;\n    P5M0 = 0x00;\n    P5M1 = 0x00;\n    CCON = 0x00;\n    CMOD = 0x08; \/\/PCA\u65f6\u949f\u4e3a\u7cfb\u7edf\u65f6\u949f\n    CL = 0x00;\n    CH = 0x00;\n    \/\/\uff0d\uff0d6\u4f4dPWM\uff0d\uff0d\n    CCAPM0 = 0x42;   \/\/PCA\u6a21\u57570\u4e3aPWM\u5de5\u4f5c\u6a21\u5f0f\n    PCA_PWM0 = 0x80; \/\/PCA\u6a21\u57570\u8f93\u51fa6\u4f4dPWM\n    CCAP0L = 0x20;   \/\/PWM\u5360\u7a7a\u6bd4\u4e3a50%[(40H-20H)\/40H]\n    CCAP0H = 0x20;\n    \/\/\uff0d\uff0d7\u4f4dPWM\uff0d\uff0d\n    CCAPM1 = 0x42;   \/\/PCA\u6a21\u57571\u4e3aPWM\u5de5\u4f5c\u6a21\u5f0f\n    PCA_PWM1 = 0x40; \/\/PCA\u6a21\u57571\u8f93\u51fa7\u4f4dPWM\n    CCAP1L = 0x20;   \/\/PWM\u5360\u7a7a\u6bd4\u4e3a75%[(80H-20H)\/80H]\n    CCAP1H = 0x20;\n    \/\/\uff0d\uff0d8\u4f4dPWM\uff0d\uff0d\n    \/\/ CCAPM2 = 0x42; \/\/PCA\u6a21\u57572\u4e3aPWM\u5de5\u4f5c\u6a21\u5f0f\n    \/\/ PCA_PWM2 = 0x00; \/\/PCA\u6a21\u57572\u8f93\u51fa8\u4f4dPWM\n    \/\/ CCAP2L = 0x20; \/\/PWM\u5360\u7a7a\u6bd4\u4e3a87.5%[(100H-20H)\/100H]\n    \/\/ CCAP2H = 0x20;\n    \/\/\uff0d\uff0d10\u4f4dPWM\uff0d\uff0d\n    CCAPM2 = 0x42;   \/\/PCA\u6a21\u57572\u4e3aPWM\u5de5\u4f5c\u6a21\u5f0f\n    PCA_PWM2 = 0xc0; \/\/PCA\u6a21\u57572\u8f93\u51fa10\u4f4dPWM\n    CCAP2L = 0x20;   \/\/PWM\u5360\u7a7a\u6bd4\u4e3a96.875%[(400H-20H)\/400H]\n    CCAP2H = 0x20;\n    CR = 1; \/\/\u542f\u52a8PCA\u8ba1\u65f6\u5668\n    while (1)\n        ;\n}<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2a\u5c0f\u7ec6\u8282\uff0c<code>PCA_PWMx<\/code>\u7684\u64cd\u4f5c\u65b9\u5f0f\u90fd\u662f\u5b57\u8282\u64cd\u4f5c\uff0c\u5e76\u6ca1\u6709\u4f4d\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u5feb\u8fdb\u5230\u7a0b\u5e8f\u5199\u5230PWM\u64cd\u4f5c\uff0c\u5230\u4e86\u6211\u559c\u6b22\u7684<code>#define<\/code>\u64cd\u4f5c\u73af\u8282\uff0c\u5199\u51fa\u4e86\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#define _PCA_PWMSetReloadValue(PCAn, valH, valL) \\\n    PCA_PWM##PCAn &amp;= 0xCD;                        \\ \/\/\u8bbe\u7f6e\u5bc4\u5b58\u5668\u4e3a\u521d\u59cb\u503c\n    PCA_PWM##PCAn |= (valH &amp; 0x03) &lt;&lt; 4;          \\ \/\/\u8bbe\u7f6e9,10\u4f4d\n    PCA_PWM##PCAn |= (valH &amp; 0x04) >> 1;          \\ \/\/\u8bbe\u7f6e11\u4f4d\n    CCAP##PCAn##H = valL; \/\/\u8bbe\u7f6e\u4f4e\u516b\u4f4d<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"44\" src=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-5-1024x44.png\" alt=\"\" class=\"wp-image-317\" srcset=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-5-1024x44.png 1024w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-5-300x13.png 300w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-5-768x33.png 768w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-5.png 1249w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u6211\u4e56\u4e56\u7684\u6309\u7167\u300a\u624b\u518c\u300bP545\u7684\u6ce8\u610f\u7684\u987a\u5e8f\u8fdb\u884c\u4e86\u8bbe\u7f6e\uff0c\u4f46\u662f\uff0c\u65e0\u8bba\u540e\u671f\u600e\u4e48\u8c03\u7528\u8be5\u5b8f\u5b9a\u4e49\u8fdb\u884c\u66f4\u6539\uff0c\u8f93\u51fa\u4e00\u76f4\u662f\u8bbe\u5b9a\u7684\u521d\u59cb\u503c\uff1a\u9ad8\u3002<\/p>\n\n\n\n<p>\u6211@#\uffe5\uff01@\uff01@#\uffe5\u8981\u75af\u4e86\uff0c\u51ed\u5565\uff1f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">03 \u540e\u8bed<\/h3>\n\n\n\n<p>\u7528\u4e32\u53e3\u4e00\u6b65\u4e00\u6b65\u8fdb\u884c\u6392\u67e5\uff0c\u6700\u540e\u5c06\u95ee\u9898\u5b9a\u4f4d\u5230\u4e86\u8fd9\u4e2a\u5b8f\u5b9a\u4e49\u5904\u3002<\/p>\n\n\n\n<p>\u7ecf\u8fc7\u89c2\u5bdf\u53d1\u73b0\uff0c\u4f8b\u7a0b\u7adf\u7136\u6ca1\u6709\u7528\u4f4d\u64cd\u4f5c\u8fdb\u884c<code>PCA_PWMx<\/code>\u7684\u6570\u636e\u66f4\u65b0\uff01<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"155\" src=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-6.png\" alt=\"\" class=\"wp-image-319\" srcset=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-6.png 683w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-6-300x68.png 300w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-6-680x155.png 680w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><figcaption>\u4f60\u8bbe\u7f6e\u4e86\u4e2a\u751a\u4e48\uff01<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u7136\u540e\u60f3\u8d77\u4e86\u67d0\u4e9b\u7279\u6b8a\u5bc4\u5b58\u5668\u4e0d\u80fd\u8fdb\u884c\u4f4d\u64cd\u4f5c\u53ea\u80fd\u8fdb\u884c\u5b57\u8282\u64cd\u4f5c\uff0c\u5c31\u5199\u51fa\u4e86\u5982\u4e0b\u4fee\u6539\u540e\u7684\u7a0b\u5e8f\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#define _PCA_PWMSetReloadValue(PCAn, valH, valL) \\\n    x = PCA_PWM##PCAn;                           \\\n    x &amp;= 0xCD;                                   \\\n    x |= (valH &amp; 0x03) &lt;&lt; 4;                     \\\n    x |= (valH &amp; 0x04) >> 1;                     \\\n    PCA_PWM##PCAn = x;                           \\\n    CCAP##PCAn##H = valL;<\/pre>\n\n\n\n<p>\u5bf9\u53d8\u91cf\u8fdb\u884c\u4f4d\u64cd\u4f5c\u540e\u518d\u76f4\u63a5\u5b57\u8282\u8d4b\u503c\u5c31\u53ef\u4ee5\u6b63\u5e38\u8fdb\u884c\u8c03\u5236\u4e86\uff0c\uff0c\uff0c<\/p>\n\n\n\n<p>\u6211\u65e0fa\u53ef\u8bf4\u554axdm\uff0c\uff0c<\/p>\n\n\n\n<p>\u8d34\u4e00\u4e2a\u6700\u540e\u6210\u529f\u8c03\u5236\u8f93\u51fa50%\u4e0e75%\u5360\u7a7a\u6bd4\u7684\u6ce2\u5f62\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"480\" src=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-7.png\" alt=\"\" class=\"wp-image-320\" srcset=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-7.png 800w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-7-300x180.png 300w, https:\/\/dt9025a.top\/wp-content\/uploads\/2021\/01\/image-7-768x461.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>\u65e5\u72d7\uff0cyyds<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u6211\u5e0c\u671b\uff0c\u6211\u4eec\u5f3a\u5927\u7684STC\uff0c\u8017\u5b50\u5c3e\u6c41\uff0c\u597d\u597d\u53cd\u601d\u3002\u4ee5\u540e\u4e0d\u8981\u518d\u72af\u8fd9\u6837\u7684\u9a6c\u864e\uff0c\u5c0f\u9a6c\u864e\uff0c\u554a\uff0c\u55ef\u2026 \u5f00\u53d1\u8005\u8981\u4ee5\u548c\u4e3a\u8d35\uff0c\u8981\u8bb2\u6b66\u5fb7\uff0c\u4e0d\u8981\u641e\u7f3a\u5370\u6f0f\u5370\u3002\u8c22\u8c22\u670b\u53cb\u4eec\uff01<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"56\" height=\"56\" src=\"https:\/\/dt9025a.top\/wp-content\/uploads\/2020\/08\/kuaikule.gif\" alt=\"\" class=\"wp-image-33\"\/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>01 \u524d\u8a00 \u5c31\u662f\u8fd9\u4e9b\u4e2a\u5bc4\u5b58\u5668 \u53d1\u751f\u4e86\u751a\u4e48\u4e8b\u5462\uff1f \u4e8b\u60c5\u662f\u8fd9\u6837\u7684\uff0c\u9879\u76ee\u9700\u8981\u7528\u5230PWM\uff0c\u5f88\u5feb\u554a\uff0c\u6211\u5c31\u60f3\u5230\u4e86\u6211\u4eec\u5389\u5bb3\u7684&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/dt9025a.top\/?p=315\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/dt9025a.top\/index.php?rest_route=\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dt9025a.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dt9025a.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dt9025a.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dt9025a.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":0,"href":"https:\/\/dt9025a.top\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"wp:attachment":[{"href":"https:\/\/dt9025a.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dt9025a.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dt9025a.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}