{"id":76,"date":"2021-05-13T00:00:00","date_gmt":"2021-05-13T00:00:00","guid":{"rendered":"https:\/\/zhewana.cn\/?p=76"},"modified":"2021-05-13T00:00:00","modified_gmt":"2021-05-13T00:00:00","slug":"76","status":"publish","type":"post","link":"https:\/\/zhewana.cn\/?p=76","title":{"rendered":"MSP432\u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"<p>\u770b\u8fc7\u7684\u6bcf\u90e8\u7535\u5f71\u548c\u756a\u5267\u603b\u6709\u4e00\u4e9b\u8bdd\u4f1a\u8ba9\u81ea\u5df1\u5370\u8c61\u6df1\u523b\uff0c\u6216\u8bb8\u4e0b\u6b21\u6478\u9c7c\u7684\u65f6\u5019\u4f1a\u5199\u4e00\u5199\u4ee5\u524d\u7684\u5427......\uff1f<\/p>\n<p><del>\u4e0d\u8fc7\u5199\u4e86\u5c31\u4e0d\u7b97\u662f\u6478\u9c7c\u4e86<\/del><\/p>\n<h2>Everybody loves Somebody<\/h2>\n<p>\u8bf4\u5230\u8fd9\u53e5\u8bdd\u8111\u5b50\u91cc\u5c31\u4e0d\u81ea\u89c9\u5730\u54cd\u8d77\u4e86\u8e69\u811a\u7684\u65e5\u5f0f\u82f1\u8bed\uff0c\u8fd9\u5c31\u662f\u88ab\u6d17\u8111\u4e86\uff1f<\/p>\n<p><strong>\u6bcf\u4e2a\u4eba\u90fd\u6709\u5176\u6240\u7231<\/strong>\uff0c\u770b\u5230\u6709\u4eba\u8fd9\u6837\u7ffb\u8bd1\u611f\u89c9\u771f\u7684\u6709\u88ab\u6696\u5230\u3002\u4f5c\u4e3a\u7eaf\u7231\u6218\u58eb\u6211\u5f53\u7136\u662f\u51b2\u7740\u7eaf\u7231\u6765\u4e86\u7389\u5b50\u5e02\u573a\uff0c\u6700\u540e\u5728\u7389\u5b50\u5e02\u573a\u91cc\u9762\u6211\u4e5f\u662f\u771f\u6b63\u7684\u770b\u5230\u4e86\u7eaf\u7231\uff0c\u53ea\u4e0d\u8fc7\u662f\u90bb\u91cc\u4e4b\u95f4\u7684\u7eaf\u7231\uff0c\u7eaf\u7eaf\u7684<strong>\u5173\u7231<\/strong>\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/2638293842.png\" alt=\"v2-c16036d2a073bbadc7a9bcf7045f7f41_720w.jpg\" title=\"v2-c16036d2a073bbadc7a9bcf7045f7f41_720w.jpg\"><\/p>\n<p>\u5154\u5c71\u771f\u7684\u592a\u597d\u4e86\uff0c\u770b\u5230\u6700\u540e\u771f\u7684\u89c9\u5f97\u6574\u4e2a\u4eba\u90fd\u88ab\u6e29\u99a8\u5305\u56f4\u7740\u3002\u867d\u7136\u770b\u7684\u5f88\u8ff7\u7cca\u4f46\u662f\u8fd8\u662f\u770b\u51fa\u4e86\u7389\u5b50\u5e7c\u5e74\u4fbf\u4e27\u5931\u4e86\u6bcd\u4eb2\uff0c\u8fd8\u80fd\u8fd9\u6837\u4e50\u89c2\u771f\u7684\u8ba9\u4eba\u5f88\u60ca\u8bb6\uff0c\u800c\u4e14\u7389\u5b50\u771f\u7684\u662f\u50bb\u50bb\u7684\uff0c\u5f88\u53ef\u7231\uff0c\u5bf9\u5e74\u7cd5\u6709\u7740\u5947\u602a\u7684\u504f\u6267\u4f46\u662f\u5e76\u4e0d\u5f71\u54cd\u8fd9\u8868\u73b0\u51fa\u5979\u5bf9\u751f\u6d3b\u7684\u70ed\u7231\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/3233831272.png\" alt=\"v2-904ffa62d33064bea2e1c8c8da1c3995.jpg\" title=\"v2-904ffa62d33064bea2e1c8c8da1c3995.jpg\"><\/p>\n<p>\u7389\u5b50\u5e02\u573a\uff0c\u662f\u5154\u5c71\uff0c\u662f\u56f4\u7ed5\u5728\u7389\u5b50\u5468\u56f4\u7684\u5e02\u573a\u3002\u4f46\u662f\u4ece\u5934\u5230\u5c3e\u771f\u7684\u6ca1\u770b\u5230\u4e00\u70b9\u5370\u8c61\u4e2d\u5e02\u573a\u8be5\u6709\u7684\u611f\u89c9\uff0c\u6bcf\u6b21\u4ea4\u6613\u90fd\u662f\u56f4\u7ed5\u7740\u7389\u5b50\u3001\u670b\u53cb\u8fdb\u884c\u7684\uff0c\u76ee\u5149\u6240\u53ca\u4e4b\u5904\u6ee1\u662f\u6177\u6168\u7684\u9988\u8d60<del>\u767d\u5ad6\u515a\u72c2\u559c<\/del>\u3002\u542c\u8bf4\u738b\u5b50\u5983\u4e00\u4e8b\uff0c\u5927\u5bb6\u90fd\u7eb7\u7eb7\u795d\u613f\u7389\u5b50\u5e78\u798f\uff0c\u53c8\u5b89\u6170\u8c46\u5927\u4e0d\u8981\u4f24\u5fc3\uff0c\u8981\u5931\u53bb\u4e00\u4e9b\u4e1c\u897f\u624d\u80fd\u5f97\u5230\u65b0\u7684\u4e1c\u897f\uff08\u5f53\u7136\u6211\u662f\u975e\u5e38\u4e0d\u5e0c\u671b\u7389\u5b50\u5f53\u4e0a\u738b\u5b50\u5983\u7684\uff09\u3002<\/p>\n<p>\u987a\u5e26\u4e00\u63d0\uff0c\u6700\u7ec8\u7389\u5b50\u62d2\u7edd\u5f53\u4e0a\u738b\u5b50\u5983\u7684\u65f6\u5019\u6211\u771f\u7684\u72c2\u559c\uff01\uff01<\/p>\n<p>\u770b\u5f97\u51fa\u7389\u5b50\u548c\u997c\u85cf\u7684\u611f\u60c5\u840c\u82bd\uff0c\u4e0d\u8fc7\u7389\u5b50\u771f\u7684\u597d\u8fdf\u949d\uff0c\u4e5f\u597d\u53ef\u7231\u3002<\/p>\n<p>\u611f\u53d7\u5f97\u5230\u8c46\u5927\u548c\u96cf\u5b50\uff08\u539f\u8c05\u6211\u5176\u5b9e\u6ca1\u8bb0\u4f4f\u5988\u5988\u7684\u540d\u5b57\uff09\u5e74\u8f7b\u7684\u65f6\u5019\u7684\u611f\u60c5\uff0c\u771f\u7684\u5f88\u8ba9\u4eba\u7fa1\u6155\u54c8\uff01<\/p>\n<p>\u53c8\u60f3\u8d77\u4e86\u9985\u5b50\u548c\u60a0\u6708\u7684\u53ef\u7231\u611f\u60c5\uff08\u5c0f\u76c6\u53cb\u4e92\u76f8\u559c\u6b22\u4ec0\u4e48\u7684\u771f\u7684\u592a\u53ef\u7231\u5566~\uff09<\/p>\n<p><del>\u5355\u8eab\u72d7\u6d41\u4e0b\u4e86\u6cea\u6c34<\/del><\/p>\n<p>\u4e0d\u5199\u4e86\u4e0d\u5199\u4e86\uff0c\u8d8a\u770b\u81ea\u5df1\u5199\u7684\u4e1c\u897f\u8d8a\u611f\u89c9:<\/p>\n<p>\u5199\u7684\u771f\u70c2\u5440T_T<\/p>\n<p>\u603b\u4e4b\u5c31\u662f<strong>\u5b8c\u7ed3\u6492\u82b1\uff01<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/1139242790.png\" alt=\"1620574802817.png\" title=\"1620574802817.png\"><\/p>\n<p>\u6478\u9c7c\u7ed3\u675f\uff0c\u8be5\u5e72\u6d3b\u4e86orz<\/p>\n<blockquote>\n<p><a href=\"https:\/\/wws.lanzoui.com\/iseTCpmf4kb\">https:\/\/wws.lanzoui.com\/iseTCpmf4kb<\/a><\/p>\n<\/blockquote>\n<p>\u8fd9\u91cc\u662f\u540e\u671f\u7684\u6211\u81ea\u5df1\uff0c\u6587\u7ae0\u7684\u6b63\u6587\u662f\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u968f\u7740\u8fdb\u5ea6\u4e00\u70b9\u4e00\u70b9\u5199\u51fa\u6765\u7684\uff0c\u73b0\u5728\u4f5c\u54c1\u5b8c\u6210\u7684\u63a5\u8fd1\u5c3e\u58f0\u4e86\uff0c\u4f46\u662f\u6211\u89c9\u5f97\u81ea\u5df1\u7684\u4e86\u89e3\u5e76\u4e0d\u591f\u591a\uff0c\u5148\u8bf4\u8bf4\u81ea\u5df1\u7684\u611f\u53d7\u5427\u3002<\/p>\n<p>\u9996\u5148\u6700\u5927\u7684\u611f\u53d7\u5c31\u662f\u4f7f\u7528TI\u7684SDK\u5e93\u51fd\u6570\u7684\u65f6\u5019\u7684\u964c\u751f\u611f\u3002\u8fd9\u91cc\u5c31\u4e0d\u5f97\u4e0d\u5bf9\u6bd4\u4e00\u4e0bHAL\u5e93\u548cSDK\u4e86\uff1a<\/p>\n<p>\u9996\u5148HAL\u7ed9\u4eba\u6700\u76f4\u89c2\u7684\u611f\u53d7\u5c31\u662f\u5c01\u88c5\u5ea6\u9ad8\uff0c\u66f4\u9002\u5408\u65b0\u624b\u4e0a\u624b\uff0c\u4e0a\u624b\u8d77\u6765\u4e5f\u5f88\u5feb\u3002\u4f46\u662f\u8fd9\u4e5f\u540c\u6837\u662fHAL\u5e93\u7684\u7f3a\u70b9\u3002<\/p>\n<p>\u5728\u4f7f\u7528HAL\u5e93\u7684\u65f6\u5019\uff0c\u8ba9\u4eba\u771f\u7684\u89c9\u5f97\u5c31\u662f\u5728\u201c\u4f7f\u7528\u201d\u3002\u56e0\u4e3a\u4f60\u4e0d\u77e5\u9053\u91cc\u9762\u5e72\u4e86\u4ec0\u4e48\uff0c\u600e\u4e48\u5e72\u7684\uff0cHAL\u7684\u5c01\u88c5\u5728\u4f60\u7684\u9762\u524d\u5c31\u662f\u4e00\u4e2a\u5de8\u5927\u7684\u9ed1\u76d2\u5b50\uff0c\u4f7f\u7528\u7684\u65f6\u5019\u4ed6\u5728\u523b\u610f\u7684\u5f15\u5bfc\u7740\u6211\u4eec\u8ba9\u6211\u4eec\u53ea\u5173\u5fc3\u201c\u80fd\u7528\u5c31\u884c\u201d\uff0c\u5374\u5ffd\u7565\u4e86\u80cc\u540e\u7684\u4e00\u4e9b\u673a\u5236\u548c\u539f\u7406\u3002\u8fd9\u4e0d\u662fHAL\u7684\u95ee\u9898\uff0cHAL\u7684\u521d\u5fc3\u5c31\u662f\u8ba9\u7a0b\u5e8f\u5458\u80fd\u8131\u79bb\u5728\u673a\u68b0\u5316\u7684\u521d\u59cb\u5316\u4e2d\u6d6a\u8d39\u7684\u65f6\u95f4\uff0c\u4f46\u662f\u6709\u4e00\u4e2a\u5de8\u5927\u7684\u524d\u63d0----\u8fd9\u4e2a\u7a0b\u5e8f\u5458\u61c2\u5f97\u5176\u4e2d\u7684\u539f\u7406\u3002\u800c\u5411\u6211\u4eec\u8fd9\u6837\u7684\u65b0\u624b\u5728\u7528\u7684\u65f6\u5019\u5c31\u771f\u7684\u53ea\u4f1a\u5173\u5fc3\u201c\u80fd\u7528\u5c31\u884c\u201d\u3002<\/p>\n<p>SDK\u5219\u4e0d\u4e00\u6837\uff0c\u5f88\u591a\u4e1c\u897f\u5728\u4e0d\u6478\u61c2\u5176\u4e2d\u7684\u539f\u7406\u4e4b\u524d\u662f\u6ca1\u529e\u6cd5\u8c03\u901a\u7684\uff0c\u8fd9\u5c31\u903c\u8feb\u7740\u4f60\u53bb\u4e0d\u65ad\u5730\u7ffb\u9605\u53c2\u8003\u624b\u518c\u3001\u7ffb\u9605\u5e93\u51fd\u6570\u624b\u518c\u3001\u67e5\u8d44\u6599\u7b49\u7b49\uff0c\u65e0\u5f62\u4e2d\u589e\u52a0\u4e86\u5b66\u4e60\u7684\u6df1\u5ea6\u4ee5\u53ca\u5bf9\u4e8e\u539f\u7406\u7684\u7406\u89e3\u3002<\/p>\n<p>\u61c2\u5f97\u4e0d\u591a\uff0c\u611f\u53d7\u5927\u6982\u5c31\u8fd9\u4e9b\uff0c\u4e0b\u9762\u662f\u6b63\u6587\u3002<\/p>\n<h2>\u7cfb\u7edf\u65f6\u949f\u6811\u4ee5\u53ca\u6ef4\u7b54\u65f6\u949f<\/h2>\n<h3>System Timer (SysTick)----\u7cfb\u7edf\u6ef4\u7b54\u65f6\u949f<\/h3>\n<blockquote>\n<p><strong>\u9700\u8981\u77e5\u9053\u7684\u5185\u5bb9\uff1a<\/strong><\/p>\n<ul>\n<li>Systick\u5185\u90e8\u542b\u6709\u4e00\u4e2a24\u4f4d\u8ba1\u6570\u5668\uff0c\u8ba1\u6570\u5668\u6700\u5927\u503c\u4e3a1&lt;&lt;24<\/li>\n<li>Systick\u8ba1\u6570\u9891\u7387\u7b49\u4e8e\u7cfb\u7edf\u4e3b\u9891\uff08MCLK\uff09<\/li>\n<li>Systick\u8ba1\u6570\u5668\u7684\u8ba1\u6570\u65b9\u5f0f\u4e3a\u9012\u51cf\u8ba1\u6570<\/li>\n<li>\n<p>Systick\u5171\u542b\u6709\u4e09\u4e2a\u5bc4\u5b58\u5668\u529f\u80fd\u5206\u522b\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>SysTick Control and Status Register (STCSR): A control and status register to configure its clock,enable the counter, enable the SysTick interrupt, and determine counter status.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\uff08\u7cfb\u7edf\u8bbe\u7f6e\u5bc4\u5b58\u5668\u5373SysTick-&gt;CTRL\uff09<\/p>\n<ul>\n<li>SysTick Reload Value Register (STRVR): The reload value for the counter, used to provide the counter's wrap value.<\/li>\n<\/ul>\n<p>\uff08\u8ba1\u6570\u5468\u671f\u5bc4\u5b58\u5668\u5373SysTick-&gt;LOAD\uff0cLOAD\u503c\u7b49\u4e8eperiod-1\uff09<\/p>\n<ul>\n<li>SysTick Current Value Register (STCVR): The current value of the counter.<\/li>\n<\/ul>\n<p>\uff08\u5f53\u524d\u8ba1\u6570\u503c\u5bc4\u5b58\u5668\u5373SysTick-&gt;VAL\uff09<\/p>\n<\/blockquote>\n<pre><code class=\"lang-C\">\/\/\u6682\u505c\u770b\u95e8\u72d7\nWDT_A_holdTimer( void );\n\/\/\u4f7f\u80fd\u6d6e\u70b9\u8fd0\u7b97\u5355\u5143\nvoid FPU_enableModule ( void );\n\n\/*\u5e38\u7528Systick\u76f8\u5173\u51fd\u6570*\/\n\/\/SysTick\u4f7f\u5931\u80fd\u51fd\u6570\nvoid SysTick_enableModule (void);\nvoid SysTick_disableModule (void);\n\/\/SysTick\u4e2d\u65ad\u4f7f\u5931\u80fd\u51fd\u6570\nvoid SysTick_enableInterrupt (void);\nvoid SysTick_disableInterrupt (void);\n\/\/\u83b7\u53d6Counter\u5468\u671f\u3001\u5f53\u524d\u503c\u51fd\u6570\nuint32_t SysTick_getPeriod (void);\nuint32_t SysTick_getValue (void);\n\/\/\u8bbe\u5b9aCounter\u5468\u671f\u51fd\u6570\nvoid SysTick_setPeriod (uint32_t period);\n\/\/\u6ce8\u518c\u6ce8\u9500SysTick\u4e2d\u65ad\u5411\u91cf\u51fd\u6570\nvoid SysTick_registerInterrupt (void(\u2217intHandler)(void));\nvoid SysTick_unregisterInterrupt (void);<\/code><\/pre>\n<h3>\u7cfb\u7edf\u65f6\u949f\u6811<\/h3>\n<blockquote>\n<p><strong>\u9700\u8981\u77e5\u9053\u7684\u5185\u5bb9\uff1a<\/strong><\/p>\n<p><strong>clock resources\uff08\u65f6\u949f\u6e90\uff09:  <\/strong><\/p>\n<p>\u2022 LFXTCLK: <strong>Low-frequency oscillator<\/strong> (LFXT) that can be used either with low-frequency 32768-Hz watch crystals, standard crystals, resonators, or external clock sources in the 32-kHz or below range. When in bypass mode, LFXTCLK can be driven with an external square wave signal in the 32-kHz or below range.<\/p>\n<p>\uff08 <strong>\u4f4e\u9891\u632f\u8361\u5668<\/strong>\uff08LFXT\uff09\u53ef\u4ee5\u4e0e32kHz\u6216\u4ee5\u4e0b\u8303\u56f4\u7684\u4f4e\u989132768-Hz\u624b\u8868\u6676\u4f53\uff0c\u6807\u51c6\u6676\u4f53\uff0c\u8c10\u632f\u5668\u6216\u5916\u90e8\u65f6\u949f\u6e90\u4e00\u8d77\u4f7f\u7528\u3002 \u5728\u65c1\u8def\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u752832kHz\u6216\u66f4\u4f4e\u8303\u56f4\u5185\u7684\u5916\u90e8\u65b9\u6ce2\u4fe1\u53f7\u6765\u9a71\u52a8LFXTCLK\u3002 \uff09<\/p>\n<p>\u2022 HFXTCLK: <strong>High-frequency oscillator <\/strong>(HFXT) that can be used with standard crystals or resonators in the 1-MHz to 48-MHz range. When in bypass mode, HFXTCLK can be driven with an external square wave signal.<\/p>\n<p>\uff08 <strong>\u9ad8\u9891\u632f\u8361\u5668<\/strong>\uff08HFXT\uff09\uff0c\u53ef\u4e0e1MHz\u81f348MHz\u8303\u56f4\u5185\u7684\u6807\u51c6\u6676\u4f53\u6216\u8c10\u632f\u5668\u4e00\u8d77\u4f7f\u7528\u3002 \u5728\u65c1\u8def\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u5916\u90e8\u65b9\u6ce2\u4fe1\u53f7\u9a71\u52a8HFXTCLK\u3002 \uff09<\/p>\n<p>\u2022 DCOCLK: <strong>Internal digitally controlled oscillator<\/strong> (DCO) with programmable frequencies and 3-MHz frequency by default<\/p>\n<p>\uff08 <strong>\u5185\u90e8\u6570\u63a7\u632f\u8361\u5668<\/strong>\uff08DCO\uff09\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5177\u6709\u53ef\u7f16\u7a0b\u9891\u7387\u548c3 MHz\u9891\u7387 \uff09<\/p>\n<p>\u2022 VLOCLK: <strong>Internal very-low-power low-frequency oscillator<\/strong> (VLO) with 9.4-kHz typical frequency<\/p>\n<p>\uff08 <strong>\u5185\u90e8\u8d85\u4f4e\u529f\u8017\u4f4e\u9891\u632f\u8361\u5668<\/strong>\uff08VLO\uff09\uff0c\u5178\u578b\u9891\u7387\u4e3a9.4kHz \uff09<\/p>\n<p>\u2022 REFOCLK : <strong>Internal, low-power low-frequency oscillator<\/strong> (REFO) with selectable 32.768-kHz or 128-kHz typical frequencies<\/p>\n<p>\uff08 <strong>\u5185\u90e8\u4f4e\u529f\u8017\u4f4e\u9891\u632f\u8361\u5668<\/strong>\uff08REFO\uff09\uff0c\u5177\u6709\u53ef\u9009\u768432.768 kHz\u6216128 kHz\u5178\u578b\u9891\u7387 \uff09<\/p>\n<p>\u2022 MODCLK: <strong>Internal low-power oscillator<\/strong> with 25-MHz typical frequency<\/p>\n<p>\uff08 <strong>\u5185\u90e8\u4f4e\u529f\u8017\u632f\u8361\u5668<\/strong>\uff0c\u5178\u578b\u9891\u7387\u4e3a25MHz \uff09<\/p>\n<p>\u2022 SYSOSC: <strong>Internal oscillator<\/strong> with 5-MHz typical frequency  <\/p>\n<p>\uff08 <strong>\u5185\u90e8\u632f\u8361\u5668<\/strong>\uff0c\u5177\u67095-MHz\u5178\u578b\u9891\u7387 \uff09<\/p>\n<p><strong>system clock signals\uff08\u65f6\u949f\u4fe1\u53f7\uff09:<\/strong>    <\/p>\n<p>\u2022ACLK: <strong>Auxiliary clock<\/strong>. ACLK is software selectable as LFXTCLK, VLOCLK, or REFOCLK. ACLK can be divided by 1, 2, 4, 8, 16, 32, 64, or 128. ACLK is software selectable by individual peripheral modules. ACLK is restricted to maximum frequency of operation of 128 kHz.<\/p>\n<p>( <strong>\u8f85\u52a9\u65f6\u949f<\/strong>\u3002 ACLK\u53ef\u901a\u8fc7\u8f6f\u4ef6\u9009\u62e9\u4e3aLFXTCLK\uff0cVLOCLK\u6216REFOCLK\u3002 ACLK\u53ef\u4ee5\u9664\u4ee51\u30012\u30014\u30018\u300116\u300132\u300164\u6216128\u3002ACLK\u662f\u53ef\u7531\u5404\u4e2a\u5916\u56f4\u6a21\u5757\u9009\u62e9\u7684\u8f6f\u4ef6\u3002 ACLK\u7684\u6700\u5927\u5de5\u4f5c\u9891\u7387\u9650\u5236\u4e3a128 kHz\u3002 )<\/p>\n<p>\u2022 MCLK: <strong>Master clock<\/strong>. MCLK is software selectable as LFXTCLK, VLOCLK, REFOCLK, DCOCLK,MODCLK, or HFXTCLK. MCLK can be divided by 1, 2, 4, 8, 16, 32, 64, or 128. MCLK is used by the CPU and peripheral module interfaces, as well as, used directly by some peripheral modules.<\/p>\n<p>( <strong>\u4e3b\u65f6\u949f<\/strong>\u3002 MCLK\u53ef\u901a\u8fc7\u8f6f\u4ef6\u9009\u62e9\u4e3aLFXTCLK\uff0cVLOCLK\uff0cREFOCLK\uff0cDCOCLK\uff0cMODCLK\u6216HFXTCLK\u3002 MCLK\u53ef\u4ee5\u9664\u4ee51\u30012\u30014\u30018\u300116\u300132\u300164\u6216128\u3002MCLK\u7531CPU\u548c\u5916\u56f4\u6a21\u5757\u63a5\u53e3\u4f7f\u7528\uff0c\u4ee5\u53ca\u76f4\u63a5\u7531\u67d0\u4e9b\u5916\u56f4\u6a21\u5757\u4f7f\u7528\u3002 )<\/p>\n<p>\u2022 HSMCLK: <strong>Subsystem master clock<\/strong>. HSMCLK is software selectable as LFXTCLK, VLOCLK,REFOCLK, DCOCLK, MODCLK, HFXTCLK. HSMCLK can be divided by 1, 2, 4, 8, 16, 32, 64, or 128.HSMCLK is software selectable by individual peripheral modules.<\/p>\n<p>( <strong>\u5b50\u7cfb\u7edf\u4e3b\u65f6\u949f<\/strong>\u3002 HSMCLK\u53ef\u4ee5\u9009\u62e9\u4e3aLFXTCLK\uff0cVLOCLK\uff0cREFOCLK\uff0cDCOCLK\uff0cMODCLK\uff0cHFXTCLK\u3002 HSMCLK\u53ef\u4ee5\u88ab1\u30012\u30014\u30018\u300116\u300132\u300164\u6216128\u5206\u9891\u3002HSMCLK\u662f\u53ef\u7531\u5404\u4e2a\u5916\u56f4\u6a21\u5757\u9009\u62e9\u7684\u8f6f\u4ef6\u3002 )<\/p>\n<p>\u2022 SMCLK: <strong>Low-speed subsystem master clock<\/strong>. SMCLK uses the HSMCLK clock resource selection for its clock resource. SMCLK can be divided independently from HSMCLK by 1, 2, 4, 8, 16, 32, 64, or 128. SMCLK is limited in frequency to half of the rated maximum frequency of HSMCLK. SMCLK is software selectable by individual peripheral modules.<\/p>\n<p>(<strong>\u4f4e\u901f\u5b50\u7cfb\u7edf\u4e3b\u65f6\u949f<\/strong>\u3002 SMCLK\u5c06HSMCLK\u65f6\u949f\u8d44\u6e90\u9009\u62e9\u7528\u4e8e\u5176\u65f6\u949f\u8d44\u6e90\u3002 \u53ef\u4ee5\u5c06SMCLK\u4e0eHSMCLK\u5206\u522b\u5206\u9891\u4e3a1\u30012\u30014\u30018\u300116\u300132\u300164\u6216128\u3002SMCLK\u7684\u9891\u7387\u9650\u5236\u4e3aHSMCLK\u989d\u5b9a\u6700\u5927\u9891\u7387\u7684\u4e00\u534a\u3002 SMCLK\u662f\u53ef\u7531\u5404\u4e2a\u5916\u56f4\u6a21\u5757\u9009\u62e9\u7684\u8f6f\u4ef6\u3002)    <\/p>\n<p>\u2022 BCLK:<strong>Low-speed backup domain clock<\/strong>. BCLK is software selectable as LFXTCLK and REFOCLK and is used primarily in the backup domain. BCLK is restricted to a maximum frequency of 32.768 kHz.  <\/p>\n<p>( <strong>\u4f4e\u901f\u5907\u4efd\u57df\u65f6\u949f<\/strong>\u3002 BCLK\u662f\u8f6f\u4ef6\u53ef\u9009\u7684LFXTCLK\u548cREFOCLK\uff0c\u4e3b\u8981\u7528\u4e8e\u5907\u4efd\u57df\u3002 BCLK\u7684\u6700\u5927\u9891\u7387\u9650\u5236\u4e3a32.768 kHz\u3002 )<\/p>\n<\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/2638293842.png\" alt=\"1622276050150.png\" title=\"1622276050150.png\"><\/p>\n<p>\u4e0a\u8ff0\u4e3aMSP432\u65f6\u949f\u7cfb\u7edf\u4ecb\u7ecd\u7684\u622a\u56fe\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u533a\u5206\u5df2\u7ecf\u5229\u7528\u4e0d\u540c\u7684\u989c\u8272\u6807\u51fa\u4e86\u4e0d\u540c\u7684\u65f6\u949f\u603b\u7ebf\u3002<\/p>\n<p>\u6839\u636e\u4e0a\u56fe\u53ef\u603b\u7ed3\u51fa\u5982\u4e0b\u65f6\u949f\u4fe1\u53f7\u548c\u65f6\u949f\u6e90\u7684\u5173\u7cfb\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u65f6\u949f\u6e90\u65f6\u949f\u4fe1\u53f7<\/th>\n<th align=\"center\">ACLK<\/th>\n<th align=\"center\">MCLK<\/th>\n<th align=\"center\">HSMCLK<\/th>\n<th align=\"center\">SMCLK<\/th>\n<th align=\"center\">BCLK<\/th>\n<th align=\"center\">\u80fd\u5426\u76f4\u63a5\u88ab\u5176\u4ed6\u5916\u8bbe\u4f7f\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\"><strong>LFXTCLK<\/strong><\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>VLO<\/strong><\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>REFO<\/strong><\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>DCOCLK<\/strong><\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>MODOSC<\/strong><\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>HFXTCLK<\/strong><\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">\u221a<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><strong>SYSOSC<\/strong><\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">-<\/td>\n<td align=\"center\">\u221a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5e38\u7528\u7cfb\u7edf\u65f6\u949f\u51fd\u6570<\/h3>\n<pre><code class=\"lang-C\">\/*\u5e38\u7528\u65f6\u949f\u6811\u76f8\u5173\u51fd\u6570*\/\n\/\/\u83b7\u53d6\u5404\u79cd\u5916\u90e8\u65f6\u949f\u6e90\u7684\u9891\u7387\uff08\u7528\u4e8e\u8c03\u8bd5\u65f6\u949f\u6811\u5f88\u65b9\u4fbf\uff09\nuint32_t CS_getACLK(void);\nuint32_t CS_getBCLK(void);\nuint32_t CS_getHSMCLK(void);\nuint32_t CS_getMCLK(void);\nuint32_t CS_getSMCLK(void);\n\/\/\u65f6\u949f\u4fe1\u53f7\u521d\u59cb\u5316\uff08\u7528\u4e8e\u8bbe\u7f6e\u65f6\u949f\u5206\u9891\uff09\nvoid CS_initClockSignal(uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider);\n\/\/\u8bbe\u7f6eDCOCLK\u9891\u7387\u8303\u56f4\u4e2d\u5fc3\uff08\u7b80\u5355\u786e\u5b9aDCOCLK\u9891\u7387\u8303\u56f4\uff0c\u540e\u9762\u9700\u8981\u52a0\u4e0a\u4e00\u4e2a\u9891\u7387\u8bbe\u7f6e\u51fd\u6570\u786e\u5b9a\u5177\u4f53\u9891\u7387\uff09\nvoid CS_setDCOCenteredFrequency (uint32_t dcoFreq);\n\/\/\u8bbe\u7f6eDCOCLK\u9891\u7387\u503c\nvoid CS_setDCOFrequency (uint32_t dcoFrequency);<\/code><\/pre>\n<h2>Digital I\/O\uff08\u6570\u5b57\u8f93\u5165\u8f93\u51fa\uff09<\/h2>\n<h3>Digital I\/O\u4ecb\u7ecd<\/h3>\n<p>\u867d\u7136\u540d\u5b57\u4e0d\u540c\uff0c\u4f46\u662f\u548cSTM\u4e2d\u7684GPIO\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<p>\u751a\u81f3\u5728DriverLib\u5e93\u7684\u624b\u518c\u4e2d\u76f4\u63a5\u7528\u4e86GPIO\u7684\u5199\u6cd5<del>\uff08\u8bf6\uff0c\u6211\u4eec\u4e0d\u88c5\u4e86\uff0c\u644a\u724c\u4e86\uff0c\u5c31\u662f\u4e00\u6837\u7684\uff01\uff09<\/del><\/p>\n<p>\u4e0d\u8fc7\u6709\u4e00\u70b9\u503c\u5f97\u6ce8\u610f\u7684\u662f\u4e00\u4e2a\u53eb\u505a\u5916\u8bbeGPIO\u7684\u4e1c\u897f\uff0c\u5b83\u5176\u5b9e\u548cGPIO\u5b8c\u5168\u4e0d\u662f\u4e00\u4e2a\u4e1c\u897f\u3002\u901a\u4fd7\u7684\u8bb2\u5176\u5b9e\u5b83\u662f\u4e3a\u5176\u4ed6\u7684\u9700\u8981\u5f15\u811a\u6765\u8fdb\u884c\u8f93\u5165\u8f93\u51fa\u7684\u5916\u8bbe\u9009\u62e9\u4e86\u5176\u9700\u8981\u7684\u5f15\u811a\u5e76\u914d\u7f6e\u4e3a\u76f8\u5e94\u7684\u6a21\u5f0f\u3002\u4f8b\u5982IIC\u3001SPI\u3001PWM\u7b49\u7b49\u3002<\/p>\n<p>\u6b63\u662f\u56e0\u6b64\u6240\u4ee5\u524d\u9762\u6211\u8bf4\u7684\u5185\u5bb9\u5176\u5b9e\u5e76\u4e0d\u4e25\u8c28\u3002\u5e94\u8be5\u662f\u8bf4\uff1a\u5728<strong>\u901a\u7528\u8f93\u5165\u8f93\u51fa\u529f\u80fd<\/strong>\u4e0a\uff0c\u4ed6\u4eec\u867d\u7136\u540d\u5b57\u4e0d\u540c\uff0c\u4f46\u662f\u548cSTM\u4e2d\u7684GPIO\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<p>\u4f46\u662f\u4ed4\u7ec6\u60f3\u4e00\u4e0b\uff0c\u8fd9\u4e24\u4e2a\u624b\u518c\u4e2d\u8868\u73b0\u51fa\u7684\u7406\u89e3\u4f3c\u4e4e\u5e76\u4e0d\u4e00\u6837\uff1aGPIO\u66f4\u50cf\u662f<strong>\u529f\u80fd\u6027\u7684\u53d9\u8ff0<\/strong>\uff0c\u8bf4\u660e\u8be5\u529f\u80fd\u4e3a\u901a\u7528\u8f93\u5165\u8f93\u51fa\uff1bDigital I\/O\u66f4\u50cf\u662f<strong>\u786c\u4ef6\u4e0a\u7684\u63cf\u8ff0<\/strong>\uff0c\u53ea\u8981\u662f\u9700\u8981\u8fdb\u884c\u201c\u6570\u5b57\u8f93\u5165\u8f93\u51fa\u201c\u7684\u529f\u80fd\u90fd\u9700\u8981\u7528\u5230Digital I\/O\u3002<\/p>\n<p>\u81f3\u4e8eDriverLib\u4e2d\u7684\u76f8\u5173\u51fd\u6570\uff0c\u6211\u5bf9\u5b83\u4eec\u7684\u8bc4\u4ef7\u662f\uff1a\u901a\u4fd7\u6613\u61c2\u3002<\/p>\n<p>\u771f\u7684\u5c31\u901a\u4fd7\u6613\u61c2\u5230\u53ea\u8981\u7ffb\u8bd1\u4e00\u4e0b\u540d\u5b57\u5c31\u77e5\u9053\u662f\u5e72\u4ec0\u4e48\u7684\u7a0b\u5ea6\u3002<\/p>\n<h3>\u5e38\u7528GPIO\u51fd\u6570\u6c47\u603b<\/h3>\n<pre><code class=\"lang-C\">\/\/GPIO\u6a21\u5f0f\u8bbe\u7f6e\nvoid GPIO_setAsOutputPin(uint_fast8_t selectedPort,uint_fast16_t selectedPins);\nvoid GPIO_setAsInputPin(uint_fast8_t selectedPort, uint_fast16_t selectedPins);\nvoid GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort,\nuint_fast16_t selectedPins);\nvoid GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort,\nuint_fast16_t selectedPins);\n\n\/\/\u5916\u8bbeGPIO\u8bbe\u7f6e\nvoid GPIO_setAsPeripheralModuleFunctionInputPin(uint_fast8_t selectedPort,uint_fast16_t selectedPins,uint_fast8_t mode);\/\/\u6a21\u5f0f\u53c2\u6570\uff1aGPIO_PRIMARY_MODULE_FUNCTION\/GPIO_SECONDARY_MODULE_FUNCTION\/GPIO_TERTIARY_MODULE_FUNCTION\nvoid GPIO_setAsPeripheralModuleFunctionOutputPin(uint_fast8_t selectedPort,uint_fast16_t selectedPins,uint_fast8_t mode);\/\/\u6a21\u5f0f\u53c2\u6570\uff1aGPIO_PRIMARY_MODULE_FUNCTION\/GPIO_SECONDARY_MODULE_FUNCTION\/GPIO_TERTIARY_MODULE_FUNCTION\n\n\/\/GPIO\u8f93\u51fa\u8bbe\u7f6e\nvoid GPIO_setOutputHighOnPin(uint_fast8_t selectedPort, uint_fast16_t\nselectedPins);\nvoid GPIO_setOutputLowOnPin(uint_fast8_t selectedPort, uint_fast16_t\nselectedPins);\nvoid GPIO_toggleOutputOnPin(uint_fast8_t selectedPort, uint_fast16_t\nselectedPins);\n\n\/\/GPIO\u8f93\u5165\u8bfb\u53d6\nuint8_t GPIO_getInputPinValue ( uint_fast8_t selectedPort, uint_fast16_t\nselectedPins );\/\/\u8fd4\u56de\uff1aGPIO_INPUT_PIN_HIGH\/GPIO_INPUT_PIN_LOW\n    \n\/\/GPIO\u4e2d\u65ad\u8bbe\u7f6e\nvoid GPIO_clearInterruptFlag ( uint_fast8_t selectedPort, uint_fast16_t\nselectedPins );\nvoid GPIO_disableInterrupt ( uint_fast8_t selectedPort, uint_fast16_t\nselectedPins );\nvoid GPIO_enableInterrupt ( uint_fast8_t selectedPort, uint_fast16_t\nselectedPins );\nvoid GPIO_interruptEdgeSelect ( uint_fast8_t selectedPort, uint_fast16_t\nselectedPins, uint_fast8_t edgeSelect );\/\/\u6a21\u5f0f\u53c2\u6570\uff1aGPIO_HIGH_TO_LOW_TRANSITION\/GPIO_LOW_TO_HIGH_TRANSITION\nuint_fast16_t GPIO_getEnabledInterruptStatus ( uint_fast8_t selectedPort );\/\/\u8fd4\u56de\u7aef\u53e3\u5f15\u811a\u7684\u903b\u8f91\u6216\u7ed3\u679c\n\/\/\u4e2d\u65ad\u5411\u91cf\u5904\u7406\nvoid GPIO_registerInterrupt ( uint_fast8_t selectedPort, void(\u2217)(void) intHandler )\nvoid GPIO_unregisterInterrupt ( uint_fast8_t selectedPort );\/\/\u6ce8\u9500\u4e2d\u65ad\u5411\u91cf<\/code><\/pre>\n<h2>\u5b9a\u65f6\u5668<\/h2>\n<h3>\u5b9a\u65f6\u5668\u4ecb\u7ecd<\/h3>\n<p>\u6211\u8ba4\u4e3aMSP432\u4e0eST\u7684\u5b9a\u65f6\u5668\u533a\u522b\u6700\u5927\u7684\u5730\u65b9\u5728\u4e8e\u5b83\u5c0632\u4f4d\u5b9a\u65f6\u5668\u548c16\u4f4d\u5b9a\u65f6\u5668\u5206\u5f00\u6765\uff0c\u5c06PWM\u7684\u529f\u80fd\u4ec5\u4ec5\u8d4b\u4e8816\u4f4d\u5b9a\u65f6\u5668\u3002<\/p>\n<p>\u672c\u6b21\u6bd4\u8d5b\u5e76\u672a\u7528\u5230\u8fc732\u4f4d\u5b9a\u65f6\u5668\uff0c\u56e0\u6b64\u6211\u4e5f\u4e0d\u597d\u591a\u8bf4\uff0c\u6b64\u5904\u4ecb\u7ecd\u6211\u4eec\u7528\u5230\u768416\u4f4d\u5b9a\u65f6\u5668\u7684\u90e8\u5206\u529f\u80fd\u3002<\/p>\n<blockquote>\n<p><strong>\u9700\u8981\u77e5\u9053\u7684\u4e1c\u897f\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b9a\u65f6\u5668\u6a21\u5757\u56fe\uff1a<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/3233831272.png\" alt=\"1622468114640.png\" title=\"1622468114640.png\"><\/p>\n<ul>\n<li>UPMODE\u662f\u4ece0\u8ba1\u6570\u5230CCR0<\/li>\n<li>UPDOWNMODE\u662f\u5148\u9012\u589e\u8ba1\u6570\u5230CCR0\u518d\u9012\u51cf\u8ba1\u6570\u52300\uff0c\u5176\u4e2dCCR0=period*1\/2<\/li>\n<li>CONTINOUSMODE\u662f\u4ece0\u8ba1\u6570\u52300xFFFF<\/li>\n<li>\n<p>\u5b9a\u65f6\u5668\u4e2d\u5e76\u6ca1\u6709\u5f71\u5b50\u5bc4\u5b58\u5668\u7684\u8bf4\u6cd5\uff0c\u4f46\u662f\u5176\u5b9e\u5b98\u65b9\u9ed8\u8ba4\u662f\u5177\u6709\u7c7b\u4f3cST\u4e2d\u5f71\u5b50\u5bc4\u5b58\u5668\u7684\u529f\u80fd\u7684\uff1a<\/p>\n<ul>\n<li>UPMODE\u4e2d\u7684\u8bf4\u660e\uff1a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/1139242790.png\" alt=\"1622467994167.png\" title=\"1622467994167.png\"><\/p>\n<ul>\n<li>UPDOWNMODE\u4e2d\u7684\u8bf4\u660e\uff1a<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/847811709.png\" alt=\"1622468221716.png\" title=\"1622468221716.png\"><\/p>\n<\/blockquote>\n<h3>\u5b9a\u65f6\u5668\u51fd\u6570<\/h3>\n<pre><code class=\"lang-C\">\/*\u76f8\u5173\u7ed3\u6784\u4f53*\/\ntypedef struct _Timer_A_ContinuousModeConfig\n{\n    uint_fast16_t clockSource;\n    uint_fast16_t clockSourceDivider;\n    \/\/\u6ce8\u610f\uff1a\u6b64\u5904\u7684\u5206\u9891\u662f\u6307\u5728\u4e3b\u9891\u7ecf\u8fc7\u5206\u9891\u540e\u5f97\u5230\u7684\u5bf9\u5e94\u65f6\u949f\u9891\u7387\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u5206\u9891\n    uint_fast16_t timerInterruptEnable_TAIE;\n    uint_fast16_t timerClear;\n} Timer_A_ContinuousModeConfig;\n\ntypedef struct _Timer_A_UpDownModeConfig\n{\n    uint_fast16_t clockSource;\n    uint_fast16_t clockSourceDivider;\n    uint_fast16_t timerPeriod;\n    uint_fast16_t timerInterruptEnable_TAIE;\n    uint_fast16_t captureCompareInterruptEnable_CCR0_CCIE;\n    uint_fast16_t timerClear;\n} Timer_A_UpDownModeConfig;\n\ntypedef struct _Timer_A_UpModeConfig\n{\n    uint_fast16_t clockSource;\n    uint_fast16_t clockSourceDivider;\n    uint_fast16_t timerPeriod;\n    uint_fast16_t timerInterruptEnable_TAIE;\n    uint_fast16_t captureCompareInterruptEnable_CCR0_CCIE;\n    uint_fast16_t timerClear;\n} Timer_A_UpModeConfig;\n\ntypedef struct _Timer_A_PWMConfig\n{\n    uint_fast16_t clockSource;\n    \/\/TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK\n    \/\/TIMER_A_CLOCKSOURCE_ACLK\n    \/\/TIMER_A_CLOCKSOURCE_SMCLK\n    \/\/TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK\n    uint_fast16_t clockSourceDivider;\n    \/\/TIMER_A_CLOCKSOURCE_DIVIDER_1\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\uff0c7\uff0c8\uff0c10\uff0c12\uff0c14\n    \/\/TIMER_A_CLOCKSOURCE_DIVIDER_16\uff0c20\uff0c24\uff0c28\uff0c32\uff0c40\uff0c48\uff0c56\uff0c64\n    uint_fast16_t timerPeriod;\n    \/\/selects the desired timer period\n    uint_fast16_t compareRegister;\n    \/\/TIMER_A_CAPTURECOMPARE_REGISTER_0\uff0c1\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\n    uint_fast16_t compareOutputMode;\n    \/\/TIMER_A_OUTPUTMODE_OUTBITVALUE,\n    \/\/TIMER_A_OUTPUTMODE_SET,\n    \/\/TIMER_A_OUTPUTMODE_TOGGLE_RESET,\n    \/\/TIMER_A_OUTPUTMODE_SET_RESET\n    \/\/TIMER_A_OUTPUTMODE_TOGGLE,\n    \/\/TIMER_A_OUTPUTMODE_RESET,\n    \/\/TIMER_A_OUTPUTMODE_TOGGLE_SET,\n    \/\/TIMER_A_OUTPUTMODE_RESET_SET\n    uint_fast16_t dutyCycle;\n    \/\/specifies the dutycycle for the generated waveform\n} Timer_A_PWMConfig;\n\n\/*\u76f8\u5173\u51fd\u6570*\/\n\/\/\u4e09\u79cd\u8ba1\u6570\u6a21\u5f0f\u914d\u7f6e\u51fd\u6570\nvoid Timer_A_configureContinuousMode (uint32_t timer, const Timer_A_ContinuousModeConfig \u2217config);\nvoid Timer_A_configureUpDownMode (uint32_t timer, const Timer_A_UpDownModeConfig\u3000\u2217config);\nvoid Timer_A_configureUpMode (uint32_t timer, const Timer_A_UpModeConfig \u2217config);\n\/\/PWM\u76f8\u5173\u51fd\u6570\nvoid Timer_A_generatePWM (uint32_t timer, const Timer_A_PWMConfig \u2217config);\nvoid Timer_A_setCompareValue (uint32_t timer, uint_fast16_t compareRegister,uint_fast16_t compareValue);\n\/\/\u4e2d\u65ad\u76f8\u5173\u51fd\u6570\nvoid Timer_A_enableInterrupt (uint32_t timer);\nvoid Timer_A_disableInterrupt (uint32_t timer);\nvoid Timer_A_clearInterruptFlag (uint32_t timer);\nvoid Timer_A_registerInterrupt (uint32_t timer, uint_fast8_t interruptSelect, void(\u2217intHandler)(void));\nvoid Timer_A_unregisterInterrupt (uint32_t timer, uint_fast8_t interruptSelect);<\/code><\/pre>\n<h2>\u7cfb\u7edf\u4e2d\u65ad\uff08NVIC\uff09<\/h2>\n<h3>\u4e00\u70b9\u5c0f\u5c0f\u60f3\u6cd5<\/h3>\n<p><strong>PS:\u6682\u4e14\u5c06Interrupt\u5f00\u5934\u7684\u51fd\u6570\u79f0\u4e3a\u7cfb\u7edf\u4e2d\u65ad\u51fd\u6570\uff0c\u800c\u5404\u4e2a\u5916\u8bbe\u4e2d\u7684\u4e2d\u65ad\u51fd\u6570\u6210\u4e3a\u5916\u8bbe\u4e2d\u65ad\u51fd\u6570\u3002<\/strong><\/p>\n<p>\u5b66\u4e60\u4e2d\u65ad\u51fd\u6570\u7684\u65f6\u5019\u80fd\u611f\u53d7\u5230\u8fd9\u4e2a\u5e93\u7684\u903b\u8f91\u548cHAL\u5e93\u6700\u5927\u7684\u5dee\u522b\u5728\u4e8e\u5bf9\u4e2d\u65ad\u5411\u91cf\u7684\u5904\u7406\uff1a<\/p>\n<p>HAL\u5e93\u5c06\u4e2d\u65ad\u5904\u7406\u51fd\u6570\u5168\u90e8\u5199\u597d\u4e86\uff0c\u7ed9\u7528\u6237\u4fdd\u7559\u4e86\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u4f5c\u4e3a\u63a5\u53e3\uff0c\u5f00\u673a\u8f7d\u5165\u4e2d\u65ad\u5411\u91cf\u8868\u7684\u65f6\u5019\u4f1a\u5c06\u6240\u6709\u7684\u4e2d\u65ad\u5904\u7406\u51fd\u6570\u90fd\u4f5c\u4e3a\u4e2d\u65ad\u5411\u91cf\u52a0\u8f7d\u597d\uff0c\u63a5\u7740\u5728\u4e2d\u65ad\u5904\u7406\u51fd\u6570\u4e2d\u8c03\u7528\u56de\u8c03\u51fd\u6570\u8fdb\u800c\u5b9e\u73b0\u5c06\u7528\u6237\u4ee3\u7801\u52a0\u5165\u4e2d\u65ad\u4e2d\u7684\u76ee\u7684\u3002\u800cSDK\u7684\u4e2d\u65ad\u5411\u91cf\u8868\u4ece\u4e00\u5f00\u59cb\u5c31\u662f\u7a7a\u7684\uff0c\u7528\u6237\u9700\u8981\u81ea\u884c\u7f16\u5199\u4e2d\u65ad\u5904\u7406\u51fd\u6570\uff0c\u5e76\u4e14\u81ea\u884c\u6ce8\u518c\u4e2d\u65ad\u5411\u91cf\uff0c\u8fdb\u800c\u5b9e\u73b0\u53d1\u751f\u4e2d\u65ad\u65f6\u5bf9\u4e2d\u65ad\u5185\u90e8\u4ee3\u7801\u7684\u8c03\u7528\u3002<\/p>\n<p>\u8bf4\u7b80\u5355\u70b9\u5c31\u662fHAL\u5e93\u68d2\u7528\u6237\u586b\u597d\u4e86\u4e2d\u65ad\u5411\u91cf\u8868\uff0c\u800cSDK\u5219\u9700\u8981\u7528\u6237\u81ea\u884c\u586b\u5199\u4e2d\u65ad\u5411\u91cf\u8868\uff0c\u4e24\u79cd\u65b9\u5f0f\u81ea\u7136\u5404\u6709\u5229\u5f0a\u3002<\/p>\n<p>HAL\u5e93\u6700\u5927\u7684\u597d\u5904\u5c31\u662f\u5b83\u7b80\u5355\uff0c\u4f7f\u7528\u7684\u65f6\u5019\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5199\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u5c31\u80fd\u5b8c\u6210\u4e2d\u65ad\u5185\u90e8\u51fd\u6570\u7684\u4e66\u5199\uff0c\u5bf9\u65b0\u624b\u53cb\u597d\u3002\u4f46\u662f\u6211\u4e2a\u4eba\u8ba4\u4e3a\u6700\u5927\u7684\u7f3a\u70b9\u5728\u4e8e\u6ca1\u6709\u7ed9\u65b0\u624b\u4e00\u4e2a\u597d\u7684\u5f15\u5bfc\uff0c\u8fd9\u4e5f\u662f\u6211\u7528\u4e86SDK\u7684\u4e2d\u65ad\u90e8\u5206\u4ee5\u540e\u6700\u5927\u7684\u611f\u53d7\uff1a\u53d7\u76ca\u532a\u6d45\u3002\u8fd9\u79cd\u51fd\u6570\u7684\u7ec4\u7ec7\u65b9\u5f0f\u80fd\u8ba9\u4eba\u66f4\u597d\u7684\u611f\u53d7\u5230\u6709\u4e00\u4e2a\u53eb\u505a\u201c\u4e2d\u65ad\u5411\u91cf\u8868\u201d\u7684\u4e1c\u897f\u4e00\u76f4\u5728\u6307\u5f15\u7740\u7a0b\u5e8f\uff0c\u8ba9\u7a0b\u5e8f\u77e5\u9053\u53d1\u751f\u4e86\u4e2d\u65ad\u4ee5\u540e\u8be5\u6267\u884c\u4ec0\u4e48\u51fd\u6570\u3002<\/p>\n<h3>\u5e38\u7528\u7cfb\u7edf\u4e2d\u65ad\u51fd\u6570<\/h3>\n<pre><code class=\"lang-C\">\/*\u4e2d\u65ad\u76f8\u5173\u51fd\u6570*\/\n\nvoid Interrupt_disableInterrupt (uint32_t interruptNumber);\nvoid Interrupt_enableInterrupt (uint32_t interruptNumber);\nvoid Interrupt_registerInterrupt(uint32_t interruptNumber,void (*intHandler)(void));\nvoid Interrupt_unregisterInterrupt(uint32_t interruptNumber);<\/code><\/pre>\n<blockquote>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u80fd\u67d0\u4e2d\u65ad\u65f6\u5fc5\u987b<strong>\u540c\u65f6\u8c03\u7528<\/strong>\u5916\u8bbe\u4e2d\u65ad\u4f7f\u80fd\u51fd\u6570\u548c\u7cfb\u7edf\u4e2d\u65ad\u4f7f\u80fd\u51fd\u6570\u3002<\/li>\n<li>\u5404\u4e2a\u5916\u8bbe\u5bf9\u5e94\u7684\u6ce8\u518c\u4e2d\u65ad\u5411\u91cf\u51fd\u6570\u5176\u5b9e\u5185\u90e8\u8c03\u7528\u4e86<strong>\u7cfb\u7edf\u4e2d\u65ad\u4f7f\u80fd\u51fd\u6570<\/strong>\u548c<strong>\u7cfb\u7edf\u6ce8\u518c\u4e2d\u65ad\u5411\u91cf\u51fd\u6570<\/strong><\/li>\n<\/ul>\n<\/blockquote>\n<h2>\u4e32\u53e3\uff08UART\uff09<\/h2>\n<h3>\u4e32\u53e3\u4ecb\u7ecd<\/h3>\n<p>\u5176\u5b9e\u4e32\u53e3\u6ca1\u5565\u597d\u4ecb\u7ecd\u7684\uff0c\u5c31\u662f\u4e3a\u4e86\u6807\u9898\u80fd\u6574\u6574\u9f50\u9f50\u6240\u4ee5\u5199\u4e86\u8fd9\u91cc\u3002<\/p>\n<p>\u5176\u5b9e\u8fd8\u662f\u770b\u5230\u4e86\u4e00\u4e9b\u770b\u8d77\u6765\u5f88\u65b0\u5947\u7684\u529f\u80fd\u6a21\u5757\u7684\uff0c\u53ea\u4e0d\u8fc7\u8fd8\u6ca1\u7528\u8d77\u6765\u8fc7\uff0c\u6240\u4ee5\u4e5f\u4e0d\u597d\u8bf4\u4ec0\u4e48\u3002<\/p>\n<p>\u6216\u8bb8\u4ee5\u540e\u518d\u6b21\u63a5\u89e6\u7684\u65f6\u5019\u4f1a\u7528\u5230\u5462\uff0c\u8fd9\u91cc\u7559\u4e2a\u5751\u5427\u3002<\/p>\n<blockquote>\n<p><strong>\u770b\u5230\u7684\u6709\u8da3\u529f\u80fd\uff1a<\/strong><\/p>\n<ul>\n<li>Automatic Baud-Rate Detection \uff08\u81ea\u52a8\u6ce2\u7279\u7387\u68c0\u6d4b\uff1f\uff09<\/li>\n<li>Automatic Error Detection  \uff08\u81ea\u52a8\u9519\u8bef\u4fa6\u6d4b\uff1f\uff09<\/li>\n<\/ul>\n<\/blockquote>\n<h3>\u5e38\u7528\u4e32\u53e3\u51fd\u6570<\/h3>\n<pre><code class=\"lang-C\">\/*\u4e32\u53e3\u914d\u7f6e\u7ed3\u6784\u4f53*\/\ntypedef struct _eUSCI_eUSCI_UART_ConfigV1\n{\n    uint_fast8_t selectClockSource;\n    uint_fast16_t clockPrescalar;\/\/\u5bf9\u5e94\u53d6\u503c\u89c1\u8bbe\u5907\u7528\u6237\u6307\u5357\uff08DEVICE USER GUIDE\uff09\n    uint_fast8_t firstModReg;     \/\/\u5bf9\u5e94\u53d6\u503c\u89c1\u8bbe\u5907\u7528\u6237\u6307\u5357\uff08DEVICE USER GUIDE\uff09\n    uint_fast8_t secondModReg;   \/\/\u5bf9\u5e94\u53d6\u503c\u89c1\u8bbe\u5907\u7528\u6237\u6307\u5357\uff08DEVICE USER GUIDE\uff09\n    uint_fast8_t parity;\n    uint_fast16_t msborLsbFirst;\n    uint_fast16_t numberofStopBits;\n    uint_fast16_t uartMode;\n    uint_fast8_t overSampling;\n    uint_fast16_t dataLength;\n} eUSCI_UART_ConfigV1;<\/code><\/pre>\n<blockquote>\n<p><strong>\u7ed3\u6784\u4f53\u5404\u90e8\u5206\u5b9a\u4e49\u53ca\u5176\u53d6\u503c\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/2342671396.png\" alt=\"1622470501084.png\" title=\"1622470501084.png\"><\/p>\n<p><strong>\u5173\u4e8e\u4e0a\u8ff0\u7ed3\u6784\u4f53\u4e2d\u6ce8\u91ca\u7684\u4e09\u4e2a\u53d8\u91cf\u7684\u53d6\u503c\u65b9\u5f0f\uff1a<\/strong><\/p>\n<p>\u5728USER GUID\u4e2d\u67e5\u8868\u53ef\u5f97\u5bf9\u5e94\u53d6\u503c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/1572131013.png\" alt=\"1622472486950.png\" title=\"1622472486950.png\"><\/p>\n<\/blockquote>\n<pre><code class=\"lang-C\">\/*\u4e32\u53e3\u51fd\u6570*\/\n\/\/\u4f7f\u80fd\u3001\u5931\u80fd\u4e32\u53e3\nvoid UART_enableModule (uint32_t moduleInstance);\nvoid UART_disableModule (uint32_t moduleInstance);\n\/\/\u521d\u59cb\u5316\u4e32\u53e3\nbool UART_initModule (uint32_t moduleInstance, const eUSCI_UART_ConfigV1 \u2217config);\n\/\/\u4e32\u53e3\u6536\u53d1\u6570\u636e\uff08\u5355\u5b57\u8282\u5f62\u5f0f\uff09\nvoid UART_transmitData (uint32_t moduleInstance, uint_fast8_t transmitData);\nuint8_t UART_receiveData (uint32_t moduleInstance);\n\/\/\u4f7f\u80fd\u3001\u5931\u80fd\u4e32\u53e3\u4e2d\u65ad\nvoid UART_enableInterrupt (uint32_t moduleInstance, uint_fast8_t mask);\nvoid UART_disableInterrupt (uint32_t moduleInstance, uint_fast8_t mask);\n\/\/\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\u4f4d\nvoid UART_clearInterruptFlag (uint32_t moduleInstance, uint_fast8_t mask);\n\/\/\u6ce8\u518c\u3001\u6ce8\u9500\u4e2d\u65ad\u5411\u91cf\nvoid UART_registerInterrupt (uint32_t moduleInstance, void(\u2217intHandler)(void));\nvoid UART_unregisterInterrupt (uint32_t moduleInstance);<\/code><\/pre>\n<blockquote>\n<p><strong>\u9700\u8981\u6ce8\u610f\u7684\u5185\u5bb9\uff1a<\/strong><\/p>\n<ul>\n<li>UART_initModule()\u51fd\u6570\u5e76\u4e0d\u80fd\u4f7f\u80fd\u4e32\u53e3\uff0c\u624b\u518c\u8bf4\u660e\u5982\u4e0b\uff1a<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/zhewana.cn\/wp-content\/uploads\/2022\/02\/1996215058.png\" alt=\"1622471002332.png\" title=\"1622471002332.png\"><\/p>\n<ul>\n<li>UART_receiveData()\u51fd\u6570\u53ea\u6709\u5728\u6ca1\u6709\u4f7f\u80fd\u4e32\u53e3\u4e2d\u65ad\u7684\u65f6\u5019\u624d\u4f1a\u8f6e\u8be2\u4e2d\u65ad\u6807\u5fd7\u4f4d\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u8fd0\u884c\uff1b\u5f53\u4f7f\u80fd\u4e2d\u65ad\u540e\u5c31\u4e0d\u4f1a\u518d\u8f6e\u8be2\u6807\u5fd7\u4f4d\u4e86\uff08\u56e0\u4e3a\u6807\u5fd7\u4f4d\u7684\u53d8\u5316\u4f1a\u5f15\u8d77\u4e32\u53e3\u4e2d\u65ad\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u4e2d\u65ad\u4e2d\u8fdb\u884c\u6570\u636e\u7684\u5904\u7406\uff09\u3002<\/li>\n<li>\u4e32\u53e3\u7684\u4e2d\u65ad\u63a5\u6536\u6ca1\u6cd5\u8fdb\u884c\u65ad\u70b9\u5f0f\u7684\u8c03\u8bd5\uff0c\u6bd5\u7adf\u63a5\u6536\u51fd\u6570\u5e76\u6ca1\u6709\u8f6e\u8be2\u6807\u5fd7\u4f4d\uff0c\u4e5f\u5c31\u4e0d\u4f1a\u7b49\u7740\u4e0b\u4e00\u4e2a\u5b57\u8282\u6570\u636e\u7684\u5230\u6765\uff0c\u4fe1\u53f7\u5728\u7ebf\u8def\u4e2d\u4f20\u8f93\u662f\u4e0d\u4f1a\u7b49\u5f85\u4f60\u4e0b\u65ad\u70b9\u8c03\u8bd5\u7684\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<h2>\u5de5\u7a0b\u51fd\u6570\u603b\u7ed3<\/h2>\n<p>\u5728\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4e3a\u4e86\u4f7f\u7528\u65b9\u4fbf\uff0c\u6211\u4eec\u5c06\u6211\u4eec\u7528\u5230\u7684\u51fd\u6570\u8fdb\u884c\u4e86\u6a21\u5757\u5316\u7684\u5c01\u88c5\uff0c\u5bf9\u5e94\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<p><strong>user.c<\/strong><\/p>\n<pre><code class=\"lang-C\">\/\/\n\/\/ Created by ZheWana on 2021\/5\/26.\n\/\/\n\n#include &quot;user.h&quot;\n\nvoid UARTRetargetInit(void) {\n\n    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN2 | GPIO_PIN3,\n                                               GPIO_PRIMARY_MODULE_FUNCTION);\n    const eUSCI_UART_ConfigV1 uartConfig =\n            {\n                    EUSCI_A_UART_CLOCKSOURCE_SMCLK,\/\/\u9009\u62e9\u65f6\u949f\u6e90\n                    6,                               \/\/In device guide:UCBRx\n                    8,                             \/\/In device guide:UCBRFx\n                    0x11,                          \/\/In device guide:UCBRSx\n                    EUSCI_A_UART_NO_PARITY,           \/\/\u6781\u6027\u8bbe\u7f6e\n                    EUSCI_A_UART_LSB_FIRST,        \/\/\u8bbe\u7f6e\u9ad8\u4f4e\u4f4d\u4f18\u5148\n                    EUSCI_A_UART_ONE_STOP_BIT,       \/\/\u505c\u6b62\u4f4d\u6570\n                    EUSCI_A_UART_MODE,               \/\/\u4e32\u53e3\u6a21\u5f0f\n                    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION,\n                    EUSCI_A_UART_8_BIT_LEN           \/\/\u6570\u636e\u957f\u5ea6\n            };\n    \/\/\u914d\u7f6e\u65f6\u949f\u6e90\uff0c\u5176\u4e2dSMCLK\u8fdb\u884c4\u5206\u9891\n    \/\/\u4e3b\u989148000000\n    \/\/SMCLK\u4e3a12000000\n    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);\n    CS_setDCOFrequency(48000000);\n    CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_4);\n    \/\/\u4e32\u53e3\u6a21\u5757\u521d\u59cb\u5316\u4ee5\u53ca\u4f7f\u80fd\n    UART_initModule(EUSCI_A0_BASE, &amp;uartConfig);\n    UART_enableModule(EUSCI_A0_BASE);\n}\n\n\/\/\u4e32\u53e3\u91cd\u5b9a\u5411\u51fd\u6570\nint UART_printf(uint32_t moduleInstance, const char *fmt, ...) {\n    va_list ap;\n    va_start(ap, fmt);\n    int length;\n    char buffer[128];\n    length = vsnprintf(buffer, 128, fmt, ap);\n    for (int i = 0; i &lt; length; i++)\n        UART_transmitData(moduleInstance, *(buffer + i));\n    va_end(ap);\n    return length;\n}\n\nint32_t CNT;\nvoid Encoder_IRQHandler(void) {\n    uint8_t temp = GPIO_getInputPinValue(GPIO_PORT_P3, GPIO_PIN2);\n    uint32_t status;\n\n    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P3);\n    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P3, status);\n    if (status &amp; GPIO_PIN3) {\n        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);\n        if (temp == GPIO_INPUT_PIN_HIGH) {\n            CNT++;\n        } else if (temp == GPIO_INPUT_PIN_LOW) {\n            CNT--;\n        }\n    }\n}\n\nvoid EncoderInit(void){\n    \/\/GPIO\u6a21\u5f0f\u8bbe\u7f6e\n    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P3, GPIO_PIN3);\n    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P3, GPIO_PIN2);\n    \/\/\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\u4f4d\n    GPIO_clearInterruptFlag(GPIO_PORT_P3, GPIO_PIN3);\n    \/\/\u4e2d\u65ad\u4f7f\u80fd\n    GPIO_enableInterrupt(GPIO_PORT_P3, GPIO_PIN3);\n    \/\/\u4e2d\u65ad\u89e6\u53d1\u8fb9\u6cbf\u9009\u62e9\n    GPIO_interruptEdgeSelect(GPIO_PORT_P3, GPIO_PIN3, GPIO_LOW_TO_HIGH_TRANSITION);\n\n    \/\/\u4e2d\u65ad\u4f7f\u80fd\u4ee5\u53ca\u4e2d\u65ad\u5411\u91cf\u6ce8\u518c\n    Interrupt_enableInterrupt(INT_PORT3);\n    Interrupt_enableMaster();\n    Interrupt_registerInterrupt(INT_PORT3, Encoder_IRQHandler);\n}\n\nvoid TIMERA0_IRQHandler(void){\n    Timer_A_clearInterruptFlag(TIMER_A0_BASE);\n    \/********\n    *\u5904\u7406\u51fd\u6570*\n    ********\/\n}\n\nvoid TimerIntuerruptInit(double period){\n    Timer_A_UpModeConfig Timer={\n            TIMER_A_CLOCKSOURCE_ACLK,\n            TIMER_A_CLOCKSOURCE_DIVIDER_1,\n            (int)(period\/1000*32000),\n            TIMER_A_TAIE_INTERRUPT_ENABLE,\n\n    };\n    Timer_A_configureUpMode(TIMER_A0_BASE,&amp;Timer);\n    Timer_A_enableInterrupt(TIMER_A0_BASE);\n    Timer_A_clearInterruptFlag(TIMER_A0_BASE);\n    Interrupt_enableInterrupt(INT_TA0_N);\n    Interrupt_enableMaster();\n    Interrupt_registerInterrupt(INT_TA0_N, TIMERA0_IRQHandler);\n    Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UP_MODE);\n}\n\nvoid Delay_ms(int freq, int time) {\n    SysTick_enableModule();\n    SysTick_setPeriod(1&lt;&lt;24);\n\n    SysTick-&gt;VAL=1&lt;&lt;24;\n    uint32_t a = SysTick_getValue();\n    while ((a - SysTick_getValue()) &lt; freq \/ 1000 * time);\n    SysTick_disableModule();\n}\n\nint uartflag = 0;\nchar ch = 'a';\nchar buff[5];\ndouble data, p, i, d, a;\nint cnt = 0;\n\nvoid UART_IRQHandler(void) {\n    buff[cnt] = UART_receiveData(EUSCI_A0_BASE);\n    cnt++;\n    if (cnt == 5)cnt = 0;\n}\n<\/code><\/pre>\n<p><strong>user.h<\/strong><\/p>\n<pre><code class=\"lang-C\">\/\/\n\/\/ Created by ZheWana on 2021\/5\/26.\n\/\/\n\n#ifndef TEMPLATE_USER_H\n#define TEMPLATE_USER_H\n\n#include &quot;ti\/devices\/msp432p4xx\/driverlib\/driverlib.h&quot;\n#include &quot;stdio.h&quot;\n#include &quot;stdarg.h&quot;\n\n\n\/\/\u4e32\u53e3\u91cd\u5b9a\u5411\u521d\u59cb\u5316\nvoid UARTRetargetInit(void);\n\/\/\u4e32\u53e3\u91cd\u5b9a\u5411\u8f93\u51fa\u51fd\u6570\nint UART_printf(uint32_t moduleInstance, const char *fmt, ...);\n\/\/\u5b9a\u65f6\u5668\u4e2d\u65ad\u5904\u7406\u51fd\u6570\nvoid TIMERA0_IRQHandler(void);\n\/\/\u5b9a\u65f6\u5668\u4e2d\u65ad\u521d\u59cb\u5316\u51fd\u6570\nvoid TimerIntuerruptInit(double period);\n\/\/\u7f16\u7801\u5668\u521d\u59cb\u5316\u51fd\u6570\nvoid EncoderInit(void);\n\/\/\u7f16\u7801\u5668\u5bf9\u5e94IO\u4e2d\u65ad\u5904\u7406\u51fd\u6570\nvoid Encoder_IRQHandler(void);\n\/\/\u6beb\u79d2\u5ef6\u65f6\u51fd\u6570\nvoid Delay_ms(int freq, int time);\n\/\/\u4e32\u53e3\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\nvoid UART_IRQHandler(void);\n#endif \/\/TEMPLATE_USER_H\n<\/code><\/pre>\n<h2>\u540e\u8bb0<\/h2>\n<p>\u56e0\u4e3a\u6bd4\u8d5b\u539f\u56e0\u6240\u4ee5\u5b66\u4e60\u7684\u5176\u5b9e\u5f88\u4ed3\u4fc3\uff0c\u6240\u4ee5\u5f88\u591a\u4e1c\u897f\u7406\u89e3\u7684\u5e76\u4e0d\u597d\uff0c\u63a5\u4e0b\u6765\u4f1a\u627e\u65f6\u95f4\u7cfb\u7edf\u7684\u597d\u597d\u5b66\u4e60\u4e00\u4e0b\u7684\u3002<\/p>\n<p><strong>\u8def\u6f2b\u6f2b\u5176\u4fee\u8fdc\u516e\uff0c\u543e\u5c06\u4e0a\u4e0b\u800c\u6c42\u7d22\u3002<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u8fc7\u7684\u6bcf\u90e8\u7535\u5f71\u548c\u756a\u5267\u603b\u6709\u4e00\u4e9b\u8bdd\u4f1a\u8ba9\u81ea\u5df1\u5370\u8c61\u6df1\u523b\uff0c\u6216\u8bb8\u4e0b\u6b21\u6478\u9c7c\u7684\u65f6\u5019\u4f1a\u5199\u4e00\u5199\u4ee5\u524d\u7684\u5427&#8230;&#8230;\uff1f \u4e0d\u8fc7\u5199\u4e86\u5c31\u4e0d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[13,14],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-embedded","tag-msp432","tag-14"],"_links":{"self":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":0,"href":"https:\/\/zhewana.cn\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhewana.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}