{"id":2829,"date":"2019-09-27T08:45:34","date_gmt":"2019-09-27T08:45:34","guid":{"rendered":""},"modified":"2019-09-27T16:45:58","modified_gmt":"2019-09-27T08:45:58","slug":"stm32%e5%8d%95%e7%89%87%e6%9c%ba%e5%ae%9e%e7%8e%b0%e6%97%a0%e6%ba%90%e8%9c%82%e9%b8%a3%e5%99%a8%e4%ba%a7%e7%94%9f%e9%9f%b3%e4%b9%90%e5%a3%b0%e7%9a%84%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2829","title":{"rendered":"STM32\u5355\u7247\u673a\u5b9e\u73b0\u65e0\u6e90\u8702\u9e23\u5668\u4ea7\u751f\u97f3\u4e50\u58f0\u7684\u8bbe\u8ba1"},"content":{"rendered":"
\n\t\u4f7f\u7528\u6709\u6e90\u8702\u9e23\u5668<\/u>\uff0c\u53ea\u80fd\u53d1\u51fa\u56fa\u5b9a\u7684”\u6ef4\u6ef4“\u58f0\uff0c\u5f53\u7136\u4e0d\u80fd\u6ee1\u8db3\u4e8e\u6b64\u5440\u3002\u4f7f\u7528\u65e0\u6e90\u8702\u9e23\u5668\uff0c\u53ea\u8981\u8f93\u51fa\u4e0d\u540c\u9891\u7387\u7684PWM\u6ce2\uff0c\u5373\u53ef\u53d1\u51fa\u4e0d\u540c\u7684\u97f3\u7b26\u3002\u4e0d\u540c\u7684\u97f3\u7b26\u7ec4\u5408\u8d77\u6765\u5c31\u662f\u4e00\u4e2a\u66f2\u5b50\u4e86\u3002<\/p>\n
\n\t1 \u4e50\u8c31\u7b80\u6790<\/p>\n
\n\t1\uff0e1 \u97f3\u9636<\/p>\n
\n\t\u97f3\u9636\u662f\u97f3\u4e50\u5fc5\u4e0d\u53ef\u5c11\u7684\u8981\u7d20\uff0c\u4e3b\u8981\u7531\u58f0\u97f3\u7684\u9891\u7387\u51b3\u5b9a\u3002\u901a\u8fc7\u7ed9\u8702\u9e23\u5668\u4e0d\u540c\u9891\u7387\u7684\u97f3\u9891<\/u>\u8109\u51b2\uff0c\u53ef\u4ee5\u4ea7\u751f\u4e0d\u540c\u7684\u97f3\u9636\uff0c\u800c\u8981\u4ea7\u751f\u67d0\u9891\u7387\u7684\u97f3\u9891\u8109\u51b2\uff0c\u6700\u7b80\u5355\u7684\u529e\u6cd5\u662f\u7b97\u51fa\u8be5\u97f3\u9891\u7684\u5468\u671f\uff0c\u7136\u540e\u5c06\u6b64\u5468\u671f\u9664\u4ee52\u5373\u4e3a\u534a\u5468\u671f\u7684\u65f6\u95f4\u3002\u901a\u8fc7\u7a0b\u5e8f\u63a7\u5236\u5355\u7247\u673a<\/u>\u67d0\u5f15\u811a\u534a\u5468\u671f\u4e3a“\u9ad8”\u3001\u534a\u5468\u671f\u4e3a“\u4f4e”\uff0c\u4e0d\u65ad\u4ea4\u66ff\u53d8\u6362\uff0c\u5373\u53ef\u4ea7\u751f\u8be5\u9891\u7387\u7684\u77e9\u5f62\u6ce2\uff0c\u63a5\u5230\u8702\u9e23\u5668\u4e0a\u5c31\u53ef\u53d1\u51fa\u8be5\u9891\u7387\u7684\u58f0\u97f3\u3002\u82e5\u60f3\u6539\u53d8\u97f3\u9636\uff0c\u53ea\u9700\u8981\u6539\u53d8\u534a\u5468\u671f\u65f6\u95f4\u5373\u53ef\u3002\u4e0b\u8868\u4e3a\u5404\u97f3\u8c03\u97f3\u7b26\u9891\u7387\u5bf9\u7167\u8868\uff0c\u636e\u6b64\u53ef\u4ea7\u751f\u4e0d\u540c\u97f3\u9636\u7684\u97f3\u7b26\u3002“#”\u8868\u793a\u534a\u97f3\uff0c\u7528\u4e8e\u4e0a\u5347\u6216\u4e0b\u964d\u534a\u4e2a\u97f3\uff0c\u4e58\u4ee52\u5c31\u63d0\u5347\u8be5\u58f0\u97f3\u4e00\u4e2a8\u5ea6\u97f3\u9636\uff0c\u51cf\u534a\u5219\u964d\u4e00\u4e2a8\u5ea6\u3002<\/p>\n
\n\t<\/p>\n
\n\t1\uff0e2 \u8282\u62cd<\/p>\n
\n\t\u82e5\u8981\u6784\u6210\u97f3\u4e50\uff0c\u5149\u6709\u97f3\u9636\u662f\u4e0d\u591f\u7684\uff0c\u8fd8\u9700\u8981\u8282\u62cd\uff0c\u4e5f\u5c31\u662f\u97f3\u7b26\u6301\u7eed\u65f6\u95f4\u7684\u957f\u77ed\uff0c\u4e00\u822c\u7528\u62cd\u6570\u8868\u793a\u3002\u81f3\u4e8e1\u62cd\u662f\u591a\u5c11\u79d2\uff0c\u6ca1\u6709\u4e25\u683c\u7684\u89c4\u5b9a\uff0c\u53ea\u8981\u8282\u62cd\u9002\u5b9c\uff0c\u58f0\u97f3\u60a6\u8033\u5373\u53ef\u3002\u5047\u5982\u67d0\u9996\u6b4c\u66f2\u7684\u8282\u594f\u662f\u6bcf\u5206\u949f120\u62cd\uff0c\u90a3\u4e481\u62cd\u4e3a0\uff0e5 s\uff0c1\uff0f4\u62cd\u4e3a0\uff0e125 s\uff0c\u4ee5\u6b64\u7c7b\u63a8\u53ef\u5f97\u5230\u5176\u4ed6\u8282\u62cd\u5bf9\u5e94\u7684\u65f6\u957f\u3002\u8fd9\u6837\uff0c\u5229\u7528\u4e0d\u540c\u7684\u9891\u7387\uff0c\u52a0\u4e0a\u4e0e\u62cd\u6570\u5bf9\u5e94\u7684\u5ef6\u65f6\uff0c\u5c31\u6784\u6210\u4e86\u4e50\u66f2\u3002<\/p>\n
\n\t2 STM32<\/u>\u4e2d\u7684\u5b9a\u65f6\u5668<\/u><\/p>\n
\n\t\u97f3\u9636\u7684\u4ea7\u751f\u4e0e\u58f0\u97f3\u9891\u7387\u6709\u5173\uff0c\u4e3a\u4e86\u5b9e\u73b0\u4e0d\u540c\u97f3\u9636\uff0c\u5fc5\u987b\u80fd\u4e3a\u8702\u9e23\u5668\u63d0\u4f9b\u4e0d\u540c\u9891\u7387\u7684\u8109\u51b2\u3002\u4e3a\u6b64\uff0c\u9009\u62e9STM32\u82af\u7247\uff0c\u5229\u7528\u5176\u81ea\u5e26\u7684\u5b9a\u65f6\u5668\uff0c\u901a\u8fc7PWM\u4ea7\u751f\u8109\u51b2\u4fe1\u53f7\u3002STM32\u4e2d\u4e00\u5171\u670911\u4e2a\u5b9a\u65f6\u5668\uff0c\u5305\u542b2\u4e2a\u9ad8\u7ea7\u63a7\u5236\u5b9a\u65f6\u5668\u30014\u4e2a\u666e\u901a\u5b9a\u65f6\u5668\u30012\u4e2a\u57fa\u672c\u5b9a\u65f6\u5668\uff0c\u4ee5\u53ca2\u4e2a\u770b\u95e8\u72d7<\/u>\u5b9a\u65f6\u5668\u548c1\u4e2a\u7cfb\u7edf\u6ef4\u7b54\u5b9a\u65f6\u5668SysTi<\/u>ek\u3002\u5176\u4e2d\uff0cTIM1\u548cTIM8\u662f\u9ad8\u7ea7\u5b9a\u65f6\u5668\uff0c\u65f6\u949f<\/u>\u7531APB2\u7684\u8f93\u51fa\u4ea7\u751f\u3002TIM2\uff5eTIM5\u662f\u666e\u901a\u5b9a\u65f6\u5668\uff0cTIM6\u548cTIM7\u662f\u57fa\u672c\u5b9a\u65f6\u5668\uff0c\u8fd96\u4e2a\u5b9a\u65f6\u5668\u7684\u65f6\u949f\u7531APB1\u7684\u8f93\u51fa\u4ea7\u751f\u3002<\/p>\n
\n\t2\uff0e1 \u5b9a\u65f6\u65f6\u957f\u7684\u8ba1\u7b97<\/p>\n
\n\t\u5b9a\u65f6\u5668\u7684\u4e00\u4e2a\u4e3b\u8981\u529f\u80fd\u5c31\u662f\u5230\u6307\u5b9a\u65f6\u95f4\u5c31\u4f1a\u4ea7\u751f\u4e00\u4e2a\u6ea2\u51fa\u4e8b\u4ef6\uff0c\u8fd9\u4e2a\u65f6\u95f4\u7684\u8bbe\u7f6e\u4e0e\u5b9a\u65f6\u5668\u65f6\u949f\u6709\u5173\uff0c\u5728\u5b9a\u65f6\u5668\u65f6\u949f\u57fa\u7840\u4e0a\u8fdb\u884c\u9884\u5206\u9891\uff0c\u8bbe\u7f6e\u8ba1\u6570\u6ea2\u51fa\u5927\u5c0f\u5373\u53ef\u3002<\/p>\n
\n\t2\uff0e1\uff0e1 \u7cfb\u7edf\u65f6\u949f\u8bbe\u7f6e<\/p>\n
\n\t\u8981\u4fdd\u8bc1\u5b9a\u65f6\u7684\u51c6\u786e\u6027\uff0c\u5fc5\u987b\u5148\u786e\u4fdd\u7cfb\u7edf\u65f6\u949f\u7684\u8bbe\u7f6e\u662f\u6211\u4eec\u6240\u9884\u671f\u7684\u3002\u5b9a\u65f6\u5668\u65f6\u949f\u5206\u914d\u53ef\u67e5\u770b\u6570\u636e\u624b\u518c\u3002\u901a\u8fc7\u7f16\u7a0b\u4f7fSYSCLK\u4e3a72 MHz\uff0cAPB1\u9884\u5206\u9891\u540e\u5f97\u5230PCLK1\u4e3a36 MHz\uff0c\u518d\u7ecfTIM2\uff5eTIM7\u500d\u9891\u5668\u5f97\u5230TIM2\uff5eTIM7\u65f6\u949f72 MHz\u3002\u65f6\u949f\u6e90\u591a\u91c7\u7528HSE\uff08\u5916\u90e8\u65f6\u949f\u6e90\uff09\uff0c\u5bf9\u4e8eSTM32F103\uff0c\u5176\u5916\u90e8\u65f6\u949f\u4e3a8 MHz\uff0c\u800cSTM32F107\u5916\u90e8\u65f6\u949f\u4e3a25 MHz\uff0c\u56e0\u6b64\uff0c\u5728\u4f7f\u7528HSE\u505a\u65f6\u949f\u6e90\u65f6\uff0c\u8fd9\u4e24\u79cd\u5668\u4ef6\u4ea7\u751fSYSCLK\u7684\u5206\u9891\u548c\u500d\u9891\u65b9\u5f0f\u4e0d\u540c\uff0c\u9700\u8981\u4f7f\u7528\u8005\u5f15\u8d77\u6ce8\u610f\u3002<\/p>\n
\n\t2\uff0e1\uff0e2 \u5b9a\u65f6\u5668\u76f8\u5173\u53c2\u6570\u8bbe\u7f6e<\/p>\n
\n\t\u5b9a\u65f6\u5668\u7684\u53c2\u6570\u7531\u7ed3\u6784\u4f53TimeBaselnitTypeDef\u5b9a\u4e49\uff0c\u4e3b\u8981\u5305\u62ec\u9884\u5206\u9891\u7cfb\u6570\u3001\u65f6\u949f\u5206\u5272\u3001\u8ba1\u6570\u5668\u6a21\u5f0f\u3001\u8ba1\u6570\u6ea2\u51fa\u5927\u5c0f\u7b49\u3002\u4f8b\u5982\uff0c\u8981\u7531TIM3\uff08\u5b9a\u65f6\u56683\uff09\u4ea7\u751f\u4e00\u4e2a\u65f6\u957f\u4e3a1 s\u7684\u5b9a\u65f6\uff0c\u9996\u5148\uff0c\u5e94\u8fdb\u884c\u7cfb\u7edf\u65f6\u949f\u7684\u8bbe\u7f6e\uff0c\u5f97\u5230TIM3CLK=72MHz\uff0c\u7136\u540e\u8fdb\u884c\u5b9a\u65f6\u5668\u8bbe\u7f6e\u3002\u5176\u4e2d\uff0c\u9884\u5206\u9891\u7cfb\u6570\u4e3a35 999\uff0c\u6b64\u65f6\uff0cTIM3\u65f6\u949f\u4e3a72 MHz\uff0f36 000=2 kHz\uff0c\u65e0\u65f6\u949f\u5206\u5272\u3002\u8bbe\u7f6e\u8ba1\u6570\u6ea2\u51fa\u5927\u5c0f\u4e3a1 999\uff0c\u5373\u6bcf\u8ba12 000\u4e2a\u6570\u5c31\u4ea7\u751f\u4e00\u4e2a\u66f4\u65b0\u4e8b\u4ef6\uff0c\u8f93\u51fa\u9891\u7387\u4e3a2 kHz\uff0f2 000=1 Hz\u3002<\/p>\n
\n\t2\uff0e2 STM32\u7684PWM\u8f93\u51fa<\/p>\n
\n\t\u8109\u51b2\u5bbd\u5ea6\u8c03\u5236\uff08Pulse Widt<\/u>h Modulation\uff0cPWM\uff09\u662f\u5229\u7528\u5fae\u5904\u7406\u5668\u7684\u6570\u5b57\u8f93\u51fa\u6765\u5bf9\u6a21\u62df\u7535\u8def<\/u>\u8fdb\u884c\u63a7\u5236\u7684\u4e00\u79cd\u975e\u5e38\u6709\u6548\u7684\u6280\u672f\uff0c\u7b80\u800c\u8a00\u4e4b\uff0c\u5c31\u662f\u5b9e\u73b0\u5bf9\u8f93\u51fa\u4fe1\u53f7\u8109\u51b2\u5bbd\u5ea6\u7684\u63a7\u5236\uff0c\u4e00\u822c\u7528\u6765\u63a7\u5236\u6b65\u8fdb\u7535\u673a<\/u>\u7b49\u3002STM32\u7684\u5b9a\u65f6\u5668\u9664\u4e86TIM6\u548cTIM7\u4e4b\u5916\uff0c\u5176\u4ed6\u7684\u5b9a\u65f6\u5668\u90fd\u53ef\u4ee5\u7528\u6765\u4ea7\u751fPWM\u8f93\u51fa\uff0c\u5176\u4e2d\uff0c\u9ad8\u7ea7\u5b9a\u65f6\u5668TIM1\u548cTIM8\u80fd\u591f\u4ea7\u751f3\u5bf9PWM\u4e92\u8865\u8f93\u51fa\uff0c\u800cTIM2\uff5eTIM5\u4e5f\u80fd\u540c\u65f6\u4ea7\u751f4\u8def\u7684PWM\u8f93\u51fa\u3002<\/p>\n
\n\t2\uff0e2\uff0e1 PWM\u8f93\u51fa\u5f15\u811a<\/p>\n
\n\tSTM32\u7ed9\u4e0d\u540c\u7684\u5b9a\u65f6\u5668\u5206\u914d\u4e86\u4e0d\u540c\u7684\u8f93\u51fa\u5f15\u811a\uff0c\u8003\u8651\u5230\u5f15\u811a\u590d\u7528\u529f\u80fd\uff0cSTM32\u8fd8\u63d0\u51fa\u4e86\u4e00\u4e2a“\u91cd\u6620\u50cf”\u7684\u6982\u5ff5\uff0c\u5c31\u662f\u901a\u8fc7\u8bbe\u7f6e\u67d0\u4e00\u4e9b\u76f8\u5173\u7684\u5bc4\u5b58\u5668<\/u>\uff0c\u4f7f\u5f97\u5728\u5176\u4ed6\u975e\u539f\u59cb\u6307\u5b9a\u7684\u5f15\u811a\u4e0a\u4e5f\u80fd\u8f93\u51faPWM\u6ce2\u5f62\uff0c\u4f46\u662f\u8fd9\u79cd\u91cd\u6620\u50cf\u4e0d\u662f\u968f\u610f\u7684\uff0c\u4f7f\u7528\u65b9\u6cd5\u53ef\u53c2\u7167\u53c2\u8003\u6587\u732e\u3002\u4f8b\u5982\uff0cTIM3\u7684\u901a\u90532\uff0c\u5728\u6ca1\u6709\u91cd\u6620\u50cf\u7684\u65f6\u5019\uff0c\u6307\u5b9a\u7684\u5f15\u811a\u662fPA7\u3002\u5982\u679c\u8bbe\u7f6e\u90e8\u5206\u91cd\u6620\u50cf\u4e4b\u540e\uff0c\u8f93\u51fa\u5c31\u88ab\u6620\u50cf\u5230PB5\u4e0a\u4e86\uff1b\u5982\u679c\u8bbe\u7f6e\u5b8c\u5168\u91cd\u6620\u50cf\u7684\u8bdd\uff0c\u8f93\u51fa\u5c31\u88ab\u6620\u50cf\u5230PC7\u4e0a\u3002<\/p>\n
\n\t2\uff0e2\uff0e2 \u5360\u7a7a\u6bd4\u7684\u8ba1\u7b97<\/p>\n
\n\t\u5360\u7a7a\u6bd4\uff08Duty Ratio\uff09\u6709\u5982\u4e0b\u542b\u4e49\uff1a\u5728\u4e00\u4e32\u7406\u60f3\u7684\u8109\u51b2\u5468\u671f\u5e8f\u5217\uff08\u5982\u65b9\u6ce2\uff09\u4e2d\uff0c\u6b63\u8109\u51b2\u7684\u6301\u7eed\u65f6\u95f4\u4e0e\u8109\u51b2\u603b\u5468\u671f\u7684\u6bd4\u503c\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u5f53TIM_Period\u4e3a1 999\u65f6\uff0c\u82e5\u60f3\u5f97\u5230\u5360\u7a7a\u6bd450\uff05\uff0c\u5219TIM_Pulse\u5e94\u8bbe\u7f6e\u4e3a\uff081999+1\uff09\uff0f2=1000\u3002<\/p>\n
\n\t3\uff0e2 \u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n
\n\t<\/p>\n
\n\t\u6539\u53d8PWM\u7684\u97f3\u8c03\uff0c\u53ef\u4ee5\u8f93\u51faDo re mi<\/u> fa so la si do\u8fd9\u6837\u76847\u4e2a\u97f3\u7b26\uff0c\u8fd8\u53ef\u4ee5\u8f93\u51fa\u4e0d\u540c\u97f3\u8c03\u7684Do re mi fa so la si do\u3002<\/p>\n
\n\t\u5728\u5b9e\u4f8b\u7a0b\u5e8f\u91cc\u9762\uff0c\u6211\u5b9a\u4e49\u4e86\u4f4e\u4e2d\u9ad8\u4e09\u4e2a\u97f3\u9636\u3002\u97f3\u7b26\u7684\u9891\u7387\u5219\u662fmbed\u63d0\u4f9b\u7684\u3002\u5df2\u7ecf\u5b8f\u5b9a\u4e49\u597d\u4e86\u3002<\/p>\n
\n\t\u53ea\u8981\u6539\u53d8PWM\u7684\u8f93\u51fa\u5468\u671f\uff0c\u5373\u53ef\u53d1\u51fa\u4e0d\u540c\u7684\u97f3\u8c03\uff08\u9891\u7387\u662f\u5468\u671f\u7684\u5012\u6570\uff09\u3002<\/p>\n
\n\t\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u5199\u4e86\u4e00\u4e2a\u97f3\u9636\u7c7b\uff08Pi<\/u>tch\uff09\uff0c\u865a\u57fa\u7c7b\u3002\u91cc\u9762\u6709\u4e00\u4e2aperf<\/u>orm\u51fd\u6570\uff0c\u53c2\u6570\u662f\u97f3\u7b26\u548c\u6301\u7eed\u65f6\u95f4\u3002\u4f8b\u5982\u8981\u53d1\u51faDo\u8fd9\u4e2a\u58f0\u97f3\uff0c\u6301\u7eed0.5s\uff0c\u53ea\u8981perform\uff081\uff0c0.5\uff09\u5c31\u597d\u3002<\/p>\n
\n\t\u8fd8\u6709\u4e00\u4e2aStop\u51fd\u6570\uff0c\u505c\u6b62\u54cd\u58f00.5s\u5219stop\uff080.5\uff09\uff0c\u65e0\u53c2\u6570\u5219\u76f4\u63a5\u505c\u6b62\u3002\u540e\u9762\u7684Low\u3001Mid\u3001High\u7c7b\u5219\u662f\u6d3e\u751f\u7c7b\uff0c\u5b9e\u73b0\u4e86Pitch\u7684\u865a\u51fd\u6570\u3002<\/p>\n
\n\t\u7a0b\u5e8f\u91cc\u9762\u5305\u62ec\uff1a<\/p>\n
\n\t1\u3001\u53d1\u51fa\u4f4e\u4e2d\u9ad8\u4e09\u4e2a\u58f0\u8c03\u7684Do re mi fa so la si do\u97f3\u3002<\/p>\n
\n\t2\u3001\u4e2d\u97f3\u7248\u7684\u5c0f\u661f\u661f\u3002<\/p>\n
\n\t3\u3001\u4f4e\u97f3\u7248\u7684\u5c0f\u661f\u661f\u3002<\/p>\n
\n\t#include “mbed.h”<\/p>\n
\n\t#define NOTE<\/u>_B031<\/p>\n
\n\t#define NOTE_C133<\/p>\n
\n\t#define NOTE_CS1 35<\/p>\n
\n\t#define NOTE_D137<\/p>\n
\n\t#define NOTE_DS1 39<\/p>\n
\n\t#define NOTE_E141<\/p>\n
\n\t#define NOTE_F144<\/p>\n
\n\t#define NOTE_FS1 46<\/p>\n
\n\t#define NOTE_G149<\/p>\n
\n\t#define NOTE_GS1 52<\/p>\n
\n\t#define NOTE_A155<\/p>\n
\n\t#define NOTE_AS1 58<\/p>\n
\n\t#define NOTE_B162<\/p>\n
\n\t#define NOTE_C265<\/p>\n
\n\t#define NOTE_CS2 69<\/p>\n
\n\t#define NOTE_D273<\/p>\n
\n\t#define NOTE_DS2 78<\/p>\n
\n\t#define NOTE_E282<\/p>\n
\n\t#define NOTE_F287<\/p>\n
\n\t#define NOTE_FS2 93<\/p>\n
\n\t#define NOTE_G298<\/p>\n
\n\t#define NOTE_GS2 104<\/p>\n
\n\t#define NOTE_A2110<\/p>\n
\n\t#define NOTE_AS2 117<\/p>\n
\n\t#define NOTE_B2123<\/p>\n
\n\t#define NOTE_C3131<\/p>\n
\n\t#define NOTE_CS3 139<\/p>\n
\n\t#define NOTE_D3147<\/p>\n
\n\t#define NOTE_DS3 156<\/p>\n
\n\t#define NOTE_E3165<\/p>\n
\n\t#define NOTE_F3175<\/p>\n
\n\t#define NOTE_FS3 185<\/p>\n
\n\t#define NOTE_G3196<\/p>\n
\n\t#define NOTE_GS3 208<\/p>\n
\n\t#define NOTE_A3220<\/p>\n
\n\t#define NOTE_AS3 233<\/p>\n
\n\t#define NOTE_B3247<\/p>\n
\n\t#define NOTE_C4262<\/p>\n
\n\t#define NOTE_CS4 277<\/p>\n
\n\t#define NOTE_D4294<\/p>\n
\n\t#define NOTE_DS4 311<\/p>\n
\n\t#define NOTE_E4330<\/p>\n
\n\t#define NOTE_F4349<\/p>\n
\n\t#define NOTE_FS4 370<\/p>\n
\n\t#define NOTE_G4392<\/p>\n
\n\t#define NOTE_GS4 415<\/p>\n
\n\t#define NOTE_A4440<\/p>\n
\n\t#define NOTE_AS4 466<\/p>\n
\n\t#define NOTE_B4494<\/p>\n
\n\t#define NOTE_C5523<\/p>\n
\n\t#define NOTE_CS5 554<\/p>\n
\n\t#define NOTE_D5587<\/p>\n
\n\t#define NOTE_DS5 622<\/p>\n
\n\t#define NOTE_E5659<\/p>\n
\n\t#define NOTE_F5698<\/p>\n
\n\t#define NOTE_FS5 740<\/p>\n
\n\t#define NOTE_G5784<\/p>\n
\n\t#define NOTE_GS5 831<\/p>\n
\n\t#define NOTE_A5880<\/p>\n
\n\t#define NOTE_AS5 932<\/p>\n
\n\t#define NOTE_B5988<\/p>\n
\n\t#define NOTE_C61047<\/p>\n
\n\t#define NOTE_CS6 1109<\/p>\n
\n\t#define NOTE_D61175<\/p>\n
\n\t#define NOTE_DS6 1245<\/p>\n
\n\t#define NOTE_E61319<\/p>\n
\n\t#define NOTE_F61397<\/p>\n
\n\t#define NOTE_FS6 1480<\/p>\n
\n\t#define NOTE_G61568<\/p>\n
\n\t#define NOTE_GS6 1661<\/p>\n
\n\t#define NOTE_A61760<\/p>\n
\n\t#define NOTE_AS6 1865<\/p>\n
\n\t#define NOTE_B61976<\/p>\n
\n\t#define NOTE_C72093<\/p>\n
\n\t#define NOTE_CS7 2217<\/p>\n
\n\t#define NOTE_D72349<\/p>\n
\n\t#define NOTE_DS7 2489<\/p>\n
\n\t#define NOTE_E72637<\/p>\n
\n\t#define NOTE_F72794<\/p>\n
\n\t#define NOTE_FS7 2960<\/p>\n
\n\t#define NOTE_G73136<\/p>\n
\n\t#define NOTE_GS7 3322<\/p>\n
\n\t#define NOTE_A73520<\/p>\n
\n\t#define NOTE_AS7 3729<\/p>\n
\n\t#define NOTE_B73951<\/p>\n
\n\t#define NOTE_C84186<\/p>\n
\n\t#define NOTE_CS8 4435<\/p>\n
\n\t#define NOTE_D84699<\/p>\n
\n\t#define NOTE_DS8 4978<\/p>\n
\n\t\/\/7\u4e2a\u97f3\u7b26\u7ec4\u6210\u4e86\u7f8e\u5999\u7684\u97f3\u4e50<\/p>\n
\n\t\/\/\u4f4eDo re mi fa so la si do<\/p>\n
\n\tint melody\uff3b\uff3d = {NOTE_C4\uff0c NOTE_D4\uff0cNOTE_E4\uff0c NOTE_F4\uff0c NOTE_G4\uff0cNOTE_A4\uff0cNOTE_B4\uff0cNOTE_C5};<\/p>\n
\n\t\/\/\u4e2dDo re mi fa so la si do<\/p>\n
\n\tint melody2\uff3b\uff3d = {NOTE_C5\uff0c NOTE_D5\uff0cNOTE_E5\uff0c NOTE_F5\uff0c NOTE_G5\uff0cNOTE_A5\uff0cNOTE_B5\uff0cNOTE_C6};<\/p>\n
\n\t\/\/\u9ad8<\/p>\n
\n\tint melody3\uff3b\uff3d = {NOTE_C6\uff0c NOTE_D6\uff0cNOTE_E6\uff0c NOTE_F6\uff0c NOTE_G6\uff0cNOTE_A6\uff0cNOTE_B6\uff0cNOTE_C7};<\/p>\n
\n\t\/\/PWM\u8f93\u51fa\u53e3<\/p>\n
\n\tPwmOut m\uff08PB_13\uff09;<\/p>\n
\n\t\/\/\u97f3\u8c03\u7c7b<\/p>\n
\n\tclass Pitch{<\/p>\n
\n\tpublic\uff1a<\/p>\n
\n\tvirtual void perfrom<\/u>\uff08int\uff0cdouble\uff09=0;<\/p>\n
\n\tvoid stop\uff08double time = 0\uff09{<\/p>\n
\n\tif<\/u>\uff08time==0\uff09<\/p>\n
\n\tm = 1;<\/p>\n
\n\telse{<\/p>\n
\n\tm = 1;<\/p>\n
\n\twai<\/u>t\uff08time\uff09;<\/p>\n
\n\t}\/\/end else<\/p>\n
\n\t}\/\/end stop<\/p>\n
\n\t};<\/p>\n
\n\tclass Low:public Pitch{<\/p>\n
\n\tpublic\uff1a<\/p>\n
\n\tvoid perfrom\uff08int index\uff0cdouble time\uff09{<\/p>\n
\n\tm.period_us\uff081000000\/melody\uff3bindex-1\uff3d\uff09;<\/p>\n
\n\tm.write\uff080.5\uff09;<\/p>\n
\n\twait\uff08time\uff09;<\/p>\n
\n\t}<\/p>\n
\n\t}
\n\t\u6765\u6e90\uff1b21ic<\/p>\n","protected":false},"excerpt":{"rendered":"
\u4f7f\u7528\u6709\u6e90 \u8702\u9e23\u5668 \uff0c\u53ea\u80fd\u53d1\u51fa\u56fa\u5b9a\u7684\u6ef4\u6ef4\u58f0\uff0c\u5f53\u7136\u4e0d\u80fd\u6ee1\u8db3\u4e8e\u6b64\u5440\u3002\u4f7f\u7528\u65e0\u6e90\u8702\u9e23\u5668\uff0c\u53ea\u8981\u8f93\u51fa\u4e0d\u540c\u9891\u7387\u7684PWM\u6ce2\uff0c\u5373\u53ef\u53d1\u51fa\u4e0d\u540c\u7684\u97f3\u7b26\u3002\u4e0d\u540c\u7684\u97f3\u7b26\u7ec4\u5408\u8d77\u6765\u5c31\u662f\u4e00\u4e2a\u66f2\u5b50\u4e86\u3002 1 \u4e50\u8c31\u7b80<\/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\/2829"}],"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=2829"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2829\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2829"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}