{"id":338,"date":"2014-08-17T13:55:14","date_gmt":"2014-08-17T04:55:14","guid":{"rendered":"http:\/\/goji2100.s199.coreserver.jp\/blog\/?p=338"},"modified":"2022-04-11T06:44:04","modified_gmt":"2022-04-10T21:44:04","slug":"mbed-nxp-lpc1768%ef%bc%8b%e2%98%86board-orange%e3%81%a7-wav%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e5%86%8d%e7%94%9f2","status":"publish","type":"post","link":"https:\/\/goji2100.com\/blog\/?p=338","title":{"rendered":"mbed NXP LPC1768\uff0b\u2606board Orange\u3067.WAV\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u751f(2)"},"content":{"rendered":"<p>\u300c<a href=\"https:\/\/goji2100.com\/blog\/?p=270\" target=\"_blank\" rel=\"noopener\">mbed NXP LPC1768\uff0b\u2606board Orange\u3067.WAV\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u751f<\/a>\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<br \/>\n\u51fa\u529b\u306ePWM\u5024\u306e\u66f8\u8fbc\u51e6\u7406\u6642\u9593\u77ed\u7e2e\u306e\u305f\u3081\u306b\u3001PWM\u5024\u3092\u6a19\u6e96\u306e\u5b9f\u6570\u5024\u3067\u306e\u66f8\u8fbc\u307f\u304b\u3089\u6574\u6570\u5024\u3067\u306e\u66f8\u8fbc\u307f\u306b\uff08\u304b\u306a\u308a\u5f37\u5f15\u306a\u65b9\u6cd5\u3067\uff09\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<br \/>\n\u5b9f\u6570\u5024\u3067\u66f8\u8fbc\u307f\u3092\u884c\u3063\u305f\u5834\u5408\u306e\u5272\u8fbc\u51e6\u7406\u6642\u9593\u306f\u7d047.6us\u3067\u3057\u305f\u304c\u3001\u6574\u6570\u5024\u3067\u306e\u66f8\u8fbc\u307f\u306b\u3057\u305f\u3053\u3068\u30671.85us\u306b\u77ed\u7e2e\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306b\u3088\u3063\u3066\u3001WAV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u8fbc\u6642\u9593\u304c1.77ms\u304b\u30891.21ms\u3068\u77ed\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><!--more--><br \/>\nPlayWav.cpp (2014\/8\/24)<br \/>\n\u5909\u66f4\u3057\u305fPWM\u51fa\u529b\u90e8\u5206<\/p>\n<pre class=\"lang:cpp decode:true\" title=\"\u5909\u66f4\u3057\u305fPWM\u51fa\u529b\u90e8\u5206\">\r\n#define BUFF_SIZE  512\r\nunsigned char  Wave_buff[BUFF_SIZE * 2];\r\n\r\n#define PWM_CLKMHZ  24  \/\/ 24MHz\r\n#define PWM_PERIOD  22  \/\/ 22us\r\n#define PWM_RATIO   (65536\/(PWM_CLKMHZ*PWM_PERIOD))\r\nint LineL_Vol = 50, LineR_Vol = 50;\r\n\r\nvoid PwmLR_Out(short lv, short rv)\r\n{\r\n  unsigned short lw = ((lv+32768) \/ (PWM_RATIO+LineL_Vol));\r\n  unsigned short rw = ((rv+32768) \/ (PWM_RATIO+LineR_Vol));\r\n  \/\/if (lw &gt;= LPC_PWM1-&gt;MR0) lw = LPC_PWM1-&gt;MR0;\r\n  \/\/if (rw &gt;= LPC_PWM1-&gt;MR0) rw = LPC_PWM1-&gt;MR0;\r\n  #if defined(_ARCH_PRO)\r\n    \/\/ Line_R(P2_0), Line_L(P2_1)\r\n    LPC_PWM1-&gt;MR1 = lw;\r\n    LPC_PWM1-&gt;MR2 = rw;\r\n    LPC_PWM1-&gt;LER |= ((1 &lt;&lt; 1) | (1 &lt;&lt; 2));\r\n  #else\r\n    \/\/ Line_R(p21), Line_L(p22)\r\n    LPC_PWM1-&gt;MR6 = lw;\r\n    LPC_PWM1-&gt;MR5 = rw;\r\n    LPC_PWM1-&gt;LER |= ((1 &lt;&lt; 6) | (1 &lt;&lt; 5));\r\n  #endif\r\n}\r\n\r\n#define _WS16(v) *(int16_t*)&amp;Wave_Buff[v]\r\nvoid ISR_Tick(void)\r\n{\r\n  if (bufGP != bufPP) {\r\n    statLED2 = LHigh;\r\n    switch (Wave_bits) {\r\n      case 8: \/\/ (omitted)\r\n        break;\r\n      case 16:\r\n        if (Wave_chs &gt; 1) {\r\n          PwmLR_Out(_WS16(bufGP), _WSV(bufGP + 2));\r\n          bufGP += 4;\r\n        } else {\r\n          PwmLR_Out(_WS16(bufGP), _WSV(bufGP));\r\n          bufGP += 2;\r\n        }\r\n        break;\r\n    }\r\n    if (bufGP &gt;= (BUFF_SIZE * 2)) bufGP = 0;\r\n    statLED2 = LLow;\r\n  }\r\n}\r\n<\/pre>\n<p><br clear=\"all\" \/><strong>\u51e6\u7406\u6642\u9593\u8a08\u6e2c<\/strong><br \/>\n\u4e0a\u8a18\u306e\u300c<a href=\"https:\/\/mbed.org\/platforms\/mbed-LPC1768\/\" target=\"_blank\" rel=\"noopener\">mbed LPC1768<\/a>\u300d\uff0b\u300c<a href=\"https:\/\/mbed.org\/users\/logic_star\/notebook\/star_board_orange\/\" target=\"_blank\" rel=\"noopener\">\u2606board Orange<\/a>\u300d\u3067\u5b9f\u884c\u3057\u305f\u3068\u304d\u306e\u51e6\u7406\u6642\u9593\u3092\u518d\u8a08\u6e2c\u3057\u307e\u3057\u305f\u3002<br \/>\n<br clear=\"all\" \/><strong>SD\u4e0a\u306e.WAV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u8fbc\u51e6\u7406\u6642\u9593\u89b3\u6e2c<\/strong>\uff08LED1\u306e\u6ce2\u5f62\uff09<\/p>\n<div id=\"attachment_339\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED311.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-339\" class=\"size-thumbnail wp-image-339\" src=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED311-150x150.png\" alt=\"\u8aad\u8fbc\u51e6\u7406\u9593\u9694\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-339\" class=\"wp-caption-text\">P10. \u8aad\u8fbc\u51e6\u7406\u9593\u9694<\/p><\/div>\n<div id=\"attachment_340\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED321.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-340\" class=\"size-thumbnail wp-image-340\" src=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED321-150x150.png\" alt=\"\u8aad\u8fbc\u51e6\u7406\u6642\u9593\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-340\" class=\"wp-caption-text\">P11. \u8aad\u8fbc\u51e6\u7406\u6642\u9593<\/p><\/div>\n<p><br clear=\"all\" \/>\u8aad\u8fbc\u6642\u9593\u306f\u7d041.21ms\u3068\u306a\u308a\u3001\u8aad\u8fbc\u307f\u4ee5\u5916\u306e\u51e6\u7406\u306b\u4f7f\u3048\u308b\u6642\u9593\u306f\u7d0457%\u3042\u308a\u307e\u3059\u3002<br \/>\n<br clear=\"all\" \/><strong>PWM\u51fa\u529b\u51e6\u7406\u6642\u9593\u89b3\u6e2c<\/strong>\uff08LED2\u306e\u6ce2\u5f62\uff09<\/p>\n<div id=\"attachment_352\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED411.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-352\" class=\"size-thumbnail wp-image-352\" src=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED411-150x150.png\" alt=\"\u5272\u8fbc\u51e6\u7406\u9593\u9694\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-352\" class=\"wp-caption-text\">P21. \u5272\u8fbc\u51e6\u7406\u9593\u9694<\/p><\/div>\n<div id=\"attachment_353\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED421.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-353\" class=\"size-thumbnail wp-image-353\" src=\"https:\/\/goji2100.com\/blog\/wp-content\/uploads\/2014\/08\/LED421-150x150.png\" alt=\"\u5272\u8fbc\u51e6\u7406\u6642\u9593\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-353\" class=\"wp-caption-text\">P22. \u5272\u8fbc\u51e6\u7406\u6642\u9593<\/p><\/div>\n<p><br clear=\"all\" \/>PWM\u9593\u9694\u306f22us\u3068\u3057\u307e\u3057\u305f\u3001\u5272\u8fbc\u307f\u51e6\u7406\u6642\u9593\u306f1.85us\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\uff08\u8d64\u8272\u304cLED2\u306e\u6ce2\u5f62\u3001\u9ec4\u8272\u306fPWM\u51fa\u529b\u306e\u6ce2\u5f62\u3067\u3059\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300cmbed NXP LPC1768\uff0b\u2606board Orange\u3067.WAV\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u751f\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002 \u51fa\u529b\u306ePWM\u5024\u306e\u66f8\u8fbc\u51e6\u7406\u6642\u9593\u77ed\u7e2e\u306e\u305f\u3081\u306b\u3001PWM\u5024\u3092\u6a19\u6e96\u306e\u5b9f\u6570\u5024\u3067\u306e\u66f8\u8fbc\u307f\u304b\u3089\u6574\u6570\u5024\u3067\u306e\u66f8\u8fbc\u307f\u306b\uff08\u304b\u306a\u308a\u5f37\u5f15\u306a\u65b9\u6cd5\u3067\uff09 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/338"}],"collection":[{"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338"}],"version-history":[{"count":30,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/338\/revisions"}],"predecessor-version":[{"id":371,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/338\/revisions\/371"}],"wp:attachment":[{"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/goji2100.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}