{"id":2646,"date":"2019-06-17T07:59:52","date_gmt":"2019-06-17T07:59:52","guid":{"rendered":""},"modified":"2019-06-17T16:00:07","modified_gmt":"2019-06-17T08:00:07","slug":"%e5%a6%82%e4%bd%95%e9%87%87%e7%94%a8msp430%e5%8d%95%e7%89%87%e6%9c%ba%e5%ae%9e%e7%8e%b0pwm%e4%bf%a1%e5%8f%b7","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2646","title":{"rendered":"\u5982\u4f55\u91c7\u7528MSP430\u5355\u7247\u673a\u5b9e\u73b0PWM\u4fe1\u53f7"},"content":{"rendered":"
\n\t\u6982\u5ff5<\/p>\n
\n\tPWM\u4fe1\u53f7\u662f\u4e00\u79cd\u5177\u6709\u56fa\u5b9a\u5468\u671f\u3001\u4e0d\u5b9a\u5360\u7a7a\u6bd4\u7684\u6570\u5b57\u4fe1\u53f7\u3002<\/p>\n
\n\t\u5982\u679cTi<\/u>mer_A\u7684\u8ba1\u6570\u5668\u5de5\u4f5c\u5728\u589e\u8ba1\u6570\u6a21\u5f0f\uff0c\u8f93\u51fa\u91c7\u7528\u8f93\u51fa\u6a21\u5f0f7\uff08\u590d\u4f4d\/\u7f6e\u4f4d\u6a21\u5f0f\uff09<\/p>\n
\n\t\u5229\u7528\u5bc4\u5b58\u5668<\/u>TAxCCR0\u63a7\u5236PWM\u6ce2\u5f62\u7684\u5468\u671f\uff0c\u7528\u5176\u4ed6\u67d0\u4e2a\u5bc4\u5b58\u5668TAxCCRx\u6765\u63a7\u5236\u5360\u7a7a\u6bd4\uff08t\u9ad8\u7535\u5e73\/ T\u5468\u671f\uff09<\/p>\n
\n\t\u9898\u76ee<\/p>\n
\n\t\u8bbeACLK = TACLK = LFXT1 = 32768Hz\uff0c MCLK = SMCLK = DCOCLK = 32 * ACLK = 1.048576MHz\uff0c\u5229\u7528TImer_A\u8f93\u51fa\u5468\u671f 512\/32768 = 15.625ms\uff0c\u5360\u7a7a\u6bd4\u5206\u522b\u4e3a75%\u548c25%\u7684PWM\u77e9\u6ce2\u5f62\u3002<\/p>\n
\n\t\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
\n\t#include “msp430<\/u>x44x.h”<\/p>\n
\n\tvoid mai<\/u>n\uff08\uff09<\/p>\n
\n\t{<\/p>\n
\n\tWDTCTL = WDTPW + WDTHOLD;<\/p>\n
\n\tFLL_CTL0 |= XCAP14PF;<\/p>\n
\n\tTACTL = TASSEL0 + TACLR; \/\/ACLK\uff0c\u6e05\u9664TAR<\/p>\n
\n\tCCR0 = 512 - 1; \/\/\u8bbe\u7f6ePWM\u5468\u671f<\/p>\n
\n\tCCTL1 = OUTMOD_7; \/\/\u6355\u83b7\/\u6bd4\u8f83\u63a7\u5236\u5bc4\u5b58\u5668\u8bbe\u7f6e\u8f93\u51fa\u6a21\u5f0f7<\/p>\n
\n\tCCR1 = 384; \/\/\u5360\u7a7a\u6bd4384\/512=0.75<\/p>\n
\n\tCCTL2 = OUTMOD_7; \/\/\u6355\u83b7\/\u6bd4\u8f83\u63a7\u5236\u5bc4\u5b58\u5668\u8bbe\u7f6e\u8f93\u51fa\u6a21\u5f0f7<\/p>\n
\n\tCCR2 = 128; \/\/\u5360\u7a7a\u6bd4128\/512=0.25<\/p>\n
\n\tP1DIR |= 0x04; \/\/P1.2\u8f93\u51fa<\/p>\n
\n\tP1SEL |= 0x04; \/\/P1.2\u4e3a\u5916\u8bbe\u6a21\u5757 TA1<\/p>\n
\n\tP2DIR |= 0x01; \/\/P2.0\u8f93\u51fa<\/p>\n
\n\tP2SEL |= 0x01; \/\/P2.0\u4e3a\u5916\u8bbe\u6a21\u5757 TA2<\/p>\n
\n\tTACTL |= MC0; \/\/TImer_A\u63a7\u5236\u5bc4\u5b58\u5668\u8bbe\u7f6e\u4e3a\u589e\u8ba1\u6570\u6a21\u5f0f<\/p>\n
\n\tfor \uff08;;\uff09<\/p>\n
\n\t{<\/p>\n
\n\t_BIS_SR\uff08LPM3_bits\uff09; \/\/\u8fdb\u5165\u4f4e\u529f\u8017\u6a21\u5f0f3<\/p>\n
\n\t_NOP\uff08\uff09;<\/p>\n
\n\t}<\/p>\n
\n\t}<\/p>\n
\n\t\u663e\u793a\u8f93\u51fa\uff1a<\/p>\n
\n\t<\/p>\n
\n\t75%\u5360\u7a7a\u6bd4\u5982\u9ec4\u8272\u6ce2\u5f62\u6240\u793a<\/p>\n
\n\t
\n\t <\/p>\n
\n\t25%\u5360\u7a7a\u6bd4\u5982\u84dd\u8272\u6ce2\u5f62\u6240\u793a<\/p>\n
\n\t25%\u6ce2\u5f62\u660e\u660e\u4e0d\u5bf9\uff01\uff01\u53ef\u6211\u4e5f\u4e0d\u77e5\u9053\u4ec0\u4e48\u539f\u56e0\uff01\u4eff\u771f\u6240\u7528\u82af\u7247\u4e3aF249\uff0c\u4ee3\u7801\u7528\u7684\u662fmsp430x44x.h<\/p>\n","protected":false},"excerpt":{"rendered":"
\u6982\u5ff5 PWM\u4fe1\u53f7\u662f\u4e00\u79cd\u5177\u6709\u56fa\u5b9a\u5468\u671f\u3001\u4e0d\u5b9a\u5360\u7a7a\u6bd4\u7684\u6570\u5b57\u4fe1\u53f7\u3002 \u5982\u679c Ti mer_A\u7684\u8ba1\u6570\u5668\u5de5\u4f5c\u5728\u589e\u8ba1\u6570\u6a21\u5f0f\uff0c\u8f93\u51fa\u91c7\u7528\u8f93\u51fa\u6a21\u5f0f7\uff08\u590d\u4f4d\/\u7f6e\u4f4d\u6a21\u5f0f\uff09 \u5229\u7528 \u5bc4\u5b58\u5668 TAxCCR0\u63a7\u5236PWM\u6ce2\u5f62\u7684\u5468\u671f\uff0c\u7528\u5176<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2646"}],"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=2646"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2646\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2646"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}