{"id":1006,"date":"2024-02-12T17:02:05","date_gmt":"2024-02-12T08:02:05","guid":{"rendered":"https:\/\/www.aqua-informatics.jp\/?p=1006"},"modified":"2024-02-13T02:19:00","modified_gmt":"2024-02-12T17:19:00","slug":"raspberry-pi-pico-%e3%81%aedma%e3%80%81adc%e3%81%a8pio%e3%82%92%e9%80%a3%e6%90%ba%e3%81%95%e3%81%9b%e3%82%8b%e8%a9%a6%e3%81%bf","status":"publish","type":"post","link":"https:\/\/www.aqua-informatics.jp\/?p=1006","title":{"rendered":"Raspberry Pi Pico \u306eDMA\u3001ADC\u3068PIO\u3092\u9023\u643a\u3055\u305b\u308b\u8a66\u307f"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.aqua-informatics.jp\/?p=1006\/#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB\" >\u306f\u3058\u3081\u306b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.aqua-informatics.jp\/?p=1006\/#%E8%A7%A3%E6%B1%BA%E3%81%AE%E6%96%B9%E6%B3%95\" >\u89e3\u6c7a\u306e\u65b9\u6cd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.aqua-informatics.jp\/?p=1006\/#%E8%AA%B2%E9%A1%8C\" >\u8ab2\u984c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.aqua-informatics.jp\/?p=1006\/#%E7%B5%90%E6%9E%9C\" >\u7d50\u679c<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB\"><\/span>\u306f\u3058\u3081\u306b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>C12880MA\u306e\u84c4\u7a4d\u6642\u9593\u3092\u6b63\u78ba\u306b\u6c7a\u3081\u308b\u305f\u3081\u306bPico\u306ePIO\u3092\u4f7f\u3063\u3066\u3001\u30af\u30ed\u30c3\u30af\u3092\u751f\u6210\u3057\u3066\u3044\u308b\u306e\u3067\u3042\u308b\u304c\u3001ADC\u306b\u95a2\u3057\u3066\u306fPython\u306e\u30eb\u30fc\u30d7\u4e2d\u3067\u30af\u30ed\u30c3\u30af\u3092\u751f\u6210\u3057\u3064\u3064ADC\u3067\u30a2\u30ca\u30ed\u30b0\u5024\u3092\u5909\u63db\u3057\u3066\u3044\u308b\u3002<br>\u3053\u308c\u3092\u30aa\u30b7\u30ed\u30b9\u30b3\u30fc\u30d7\u3067\u89b3\u5bdf\u3057\u3066\u3044\u308b\u3068\u3001\u7d50\u69cb\u306a\u9593\u304c\u958b\u304f\u3053\u3068\u304c\u3042\u308b\u3002\u7279\u306b\u5f97\u3089\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306b\u554f\u984c\u304c\u3042\u308b\u3088\u3046\u306b\u306f\u898b\u3048\u306a\u3044\u304c\u3001\u6c17\u6301\u3061\u304c\u60aa\u3044\u306e\u3067\u6539\u5584\u3057\u305f\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E6%B1%BA%E3%81%AE%E6%96%B9%E6%B3%95\"><\/span>\u89e3\u6c7a\u306e\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>PIO\u3067CLK\u4fe1\u53f7\u3092\u7acb\u3061\u4e0a\u3052\u3066\u3001\u4e0b\u3052\u308b\u3002CM12880MA\u304cVideo\u4fe1\u53f7\u3092\u51fa\u529b\u3059\u308b\u3002DMA\u304cADC\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8ee2\u9001\u3001\u8ee2\u9001\u3055\u308c\u305f\u3053\u3068\u3092PIO\u304c\u77e5\u308b\u305f\u3081\u306b\u8ee2\u9001\u5148\u306fPIO\u306eTX FIFO\u306b\u3059\u308b\u3002PIO\u304cPull\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3053\u3068\u3067\u3001PIO\u304c\u6b21\u306eCLK\u3092\u51fa\u529b\u3001\u3064\u3044\u3067\u3001Pull\u3057\u305f\u30c7\u30fc\u30bf\u3092RX FIFO\u306bPush\u3001Push\u3055\u308c\u308b\u3068\u5225\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306eDMA\u304cPython\u5074\u306b\u7528\u610f\u3057\u305f\u30e1\u30e2\u30ea\u306bRX FIFO\u306e\u5185\u5bb9\u3092\u8ee2\u9001\u3059\u308b\u3002PIO\u3067\u306f288\u500b\u306e\u30c7\u30fc\u30bf\u7528\u306e\u30ab\u30a6\u30f3\u30bf\u3067\u4e00\u9023\u306e\u52d5\u4f5c\u3092\u5236\u5fa1\u3059\u308b\u3002\u3067\u304d\u308b\u304b\uff1fCLK\u3092\u51fa\u529b\u3057\u3066\u304b\u3089\u3001Pull\u304b\u306a\uff1fMicroPython\u5074\u306f\u3053\u306e\u4e00\u9023\u306e\u52d5\u4f5c\u306e\u958b\u59cb\u3092\u6307\u793a\u3059\u308b\u3060\u3051\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AA%B2%E9%A1%8C\"><\/span>\u8ab2\u984c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>DMA\u3092Python\u304b\u3089\u4f7f\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u3002\u3068\u308a\u3042\u3048\u305a\u3001Pico\u306e\u30ec\u30b8\u30b9\u30bf\u3092\u76f4\u63a5\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u6b21\u306e\u30da\u30fc\u30b8\u3092\u53c2\u8003\u306b\u3057\u305f\u3002uctypes\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/iosoft.blog\/pico-adc-dma\">https:\/\/iosoft.blog\/pico-adc-dma<\/a><\/p>\n\n\n\n<p>\u305f\u3060\u3001\u3053\u306e\u30b5\u30a4\u30c8\u306erp_devices.py\u306b\u306fPIO\u306e\u5b9a\u7fa9\u3084\u4e00\u90e8\u7701\u7565\u3055\u308c\u3066\u3044\u308b\u3068\u3053\u308d\u304c\u3042\u3063\u305f\u306e\u3067\u3001Datasheet\u3092\u898b\u306a\u304c\u3089\u8ffd\u52a0\u3057\u3066\u307f\u305f\u3002<br>\u3046\u307e\u304f\u52d5\u3044\u305f\u3089\u3001\u4e0a\u8a18\u30b5\u30a4\u30c8\u4e3b\u306b\u76f8\u8ac7\u3057\u3066\u307f\u308b\u304b\uff1f<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># DMA: RP2040 datasheet 2.5.7\nDMA_CTRL_TRIG_FIELDS = {\n    &quot;AHB_ERROR&quot;:   31&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;READ_ERROR&quot;:  30&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;WRITE_ERROR&quot;: 29&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;BUSY&quot;:        24&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;SNIFF_EN&quot;:    23&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;BSWAP&quot;:       22&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;IRQ_QUIET&quot;:   21&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;TREQ_SEL&quot;:    15&lt;&lt;BF_POS | 6&lt;&lt;BF_LEN | BFUINT32,\n    &quot;CHAIN_TO&quot;:    11&lt;&lt;BF_POS | 4&lt;&lt;BF_LEN | BFUINT32,\n    &quot;RING_SEL&quot;:    10&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;RING_SIZE&quot;:    6&lt;&lt;BF_POS | 4&lt;&lt;BF_LEN | BFUINT32,\n    &quot;INCR_WRITE&quot;:   5&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;INCR_READ&quot;:    4&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;DATA_SIZE&quot;:    2&lt;&lt;BF_POS | 2&lt;&lt;BF_LEN | BFUINT32,\n    &quot;HIGH_PRIORITY&quot;:1&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32,\n    &quot;EN&quot;:           0&lt;&lt;BF_POS | 1&lt;&lt;BF_LEN | BFUINT32\n}<\/code><\/pre><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>\/\/ -----------------------------------------------------------------------------\n\/\/ Field       : DMA_CH0_CTRL_TRIG_AHB_ERROR\n\/\/ Description : Logical OR of the READ_ERROR and WRITE_ERROR flags. The channel\n\/\/               halts when it encounters any bus error, and always raises its\n\/\/               channel IRQ flag.\n#define DMA_CH0_CTRL_TRIG_AHB_ERROR_RESET  _u(0x0)\n#define DMA_CH0_CTRL_TRIG_AHB_ERROR_BITS   _u(0x80000000)\n#define DMA_CH0_CTRL_TRIG_AHB_ERROR_MSB    _u(31)\n#define DMA_CH0_CTRL_TRIG_AHB_ERROR_LSB    _u(31)\n#define DMA_CH0_CTRL_TRIG_AHB_ERROR_ACCESS &quot;RO&quot;\n\/\/ -----------------------------------------------------------------------------\n\/\/ Field       : DMA_CH0_CTRL_TRIG_READ_ERROR\n\/\/ Description : If 1, the channel received a read bus error. Write one to\n\/\/               clear.\n\/\/               READ_ADDR shows the approximate address where the bus error was\n\/\/               encountered (will not be earlier, or more than 3 transfers\n\/\/               later)\n#define DMA_CH0_CTRL_TRIG_READ_ERROR_RESET  _u(0x0)\n#define DMA_CH0_CTRL_TRIG_READ_ERROR_BITS   _u(0x40000000)\n#define DMA_CH0_CTRL_TRIG_READ_ERROR_MSB    _u(30)\n#define DMA_CH0_CTRL_TRIG_READ_ERROR_LSB    _u(30)\n#define DMA_CH0_CTRL_TRIG_READ_ERROR_ACCESS &quot;WC&quot;\n\/\/ -----------------------------------------------------------------------------<\/code><\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>\u5de6\u304c\u3001Python\u306euctypes\u5411\u3051\u306e\u8a18\u8ff0\u3001\u3061\u3087\u3063\u3068\u5206\u3051\u304c\u308f\u304b\u3089\u306a\u3044\u3002\u5947\u5999\u3060\u304c\u3001 \u3068\u308a\u3042\u3048\u305a\u6307\u5b9a\u65b9\u6cd5\u306f\u308f\u304b\u3063\u305f\u3002\u53f3\u304cpico-sdk\u306b\u3042\u308b\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\u3067AHB_ERROR\u3068READ_ERROR\u306e\u8a72\u5f53\u90e8\u5206\u3001\u308f\u304b\u308a\u3084\u3059\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%B5%90%E6%9E%9C\"><\/span>\u7d50\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>ADC\u304b\u3089\u30e1\u30e2\u30ea\u4e0a\u306b\u30c7\u30fc\u30bf\u3092\u8ee2\u9001\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3002\u305f\u3060\u3057\u3001\u8907\u6570\u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001ADC FIFO\u306b8\u500b\u307b\u3069\u30c7\u30fc\u30bf\u304c\u6b8b\u308b\u554f\u984c\u304c\u3042\u308b\u3002\u3053\u308c\u3092\u8aad\u307f\u51fa\u3055\u305a\u306b\u30af\u30ea\u30a2\u3059\u308b\u826f\u3044\u65b9\u6cd5\u306a\u3044\u306e\u304b\u306a\uff1f\u4eca\u56de\u306f\u4e00\u3064\u306e\u30c7\u30fc\u30bf\u3067\u5341\u5206\u306a\u306e\u3067\u3001\u5f8c\u306e\u8ab2\u984c\u3068\u3057\u3066\u304a\u304f\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u6b21\u306fDMA\u3067\u5024\u3092PIO\u306eTX FIFO\u306b\u8ee2\u9001\u3057\u3066\u307f\u308b\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b C12880MA\u306e\u84c4\u7a4d\u6642\u9593\u3092\u6b63\u78ba\u306b\u6c7a\u3081\u308b\u305f\u3081\u306bPico\u306ePIO\u3092\u4f7f\u3063\u3066\u3001\u30af\u30ed\u30c3\u30af\u3092\u751f\u6210\u3057\u3066\u3044\u308b\u306e\u3067\u3042\u308b\u304c\u3001ADC\u306b\u95a2\u3057\u3066\u306fPython\u306e\u30eb\u30fc\u30d7\u4e2d\u3067\u30af\u30ed\u30c3\u30af\u3092\u751f\u6210\u3057\u3064\u3064ADC\u3067\u30a2\u30ca\u30ed\u30b0\u5024\u3092\u5909\u63db\u3057\u3066\u3044\u308b\u3002\u3053\u308c\u3092\u30aa\u30b7 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"common","vkexunit_cta_each_option":"","_lightning_design_setting":{"layout":"default"},"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/1006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1006"}],"version-history":[{"count":8,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/1006\/revisions"}],"predecessor-version":[{"id":1016,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/1006\/revisions\/1016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}