{"id":874,"date":"2024-08-14T17:40:42","date_gmt":"2024-08-14T09:40:42","guid":{"rendered":"http:\/\/8.153.64.192\/?page_id=874"},"modified":"2024-08-16T14:15:05","modified_gmt":"2024-08-16T06:15:05","slug":"%e9%a9%b1%e5%8a%a8%e8%a1%a5%e5%85%85%ef%bc%9aexample_adc_circle","status":"publish","type":"page","link":"http:\/\/www.agm-support.com.cn\/index.php\/sample-page\/%e9%a9%b1%e5%8a%a8%e8%a1%a5%e5%85%85%ef%bc%9aexample_adc_circle\/","title":{"rendered":"\u9a71\u52a8\u8865\u5145\uff1aexample_adc_circle"},"content":{"rendered":"\n<p>\/\/example_adc_circle.c<\/p>\n\n\n\n<p>#ifdef IPS_ANALOG_IP<\/p>\n\n\n\n<p>#include \"example.h\"<\/p>\n\n\n\n<p>#include \"analog_ip.h\"<\/p>\n\n\n\n<p>\/\/<br>\/\/\u5f00\u542fDMA\u65b9\u5f0f\u6765\u5faa\u73af\u8bfb\u53d6ADC\u7684\u591a\u4e2achannal\u7684\u503c<br>\/\/\u8bfb\u5b8c\u540e\uff0c\u6570\u636e\u653e\u5230adc_table\u6570\u7ec4\u3002<br>\/\/<br>\/\/\u8fd9\u91cc\u7ed9\u51fa\u4e24\u4e2a\u793a\u4f8b:<br>\/\/\u4e00\u4e2a\u662f\u8c03\u7528\u4e86DMAC_ConfigCircular\uff0c\u8fd9\u4e2a\u51fd\u6570\u662fSDK1.3.2\u4ee5\u540e\u65b0\u589e\u7684\u3002\u4e00\u4e2a\u662f\u6ca1\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u7684\u3002<br>\/\/\u5176\u5b9e\u4e24\u4e2a\u793a\u4f8b\u6700\u7ec8\u8d70\u7684\u6d41\u7a0b\u90fd\u662f\u4e00\u6837\u7684\u3002<\/p>\n\n\n\n<p>static uint32_t sclk_div = 9; \/\/ Divided by 20 = (9 + 1) * 2<br>static uint32_t adc_table[2]; \/\/\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u53ea\u91c7\u96c6\u4e86\u4e24\u8def\uff0c\u8fd9\u91cc\u5c31\u7ed92\u5c31\u884c\u4e86<\/p>\n\n\n\n<p>\/\/ \u6d4b\u8bd5\u5faa\u73af\u8bfb\u53d6ADC<br>DMAC_LLI_TypeDef circular_lli; \/\/\u5fc5\u987b\u5b9a\u4e49\u4e3a\u5168\u5c40\u6216\u9759\u6001\u53d8\u91cf\uff0c\u4e0d\u80fd\u662f\u5c40\u90e8\u53d8\u91cf\u3002\u56e0\u4e3aDMA\u5728\u8fd0\u884c\u4e2d\uff0c\u4f1a\u6301\u7eed\u4f7f\u7528\u3002\u5c40\u90e8\u53d8\u91cf\u5728\u9000\u51fa\u51fd\u6570\u540e\u4f1a\u91ca\u653e\u6389\u3002<\/p>\n\n\n\n<p>\/\/\u4f7f\u7528\u4e86DMAC_ConfigCircular\u51fd\u6570\u7684\u3002<br>void TestCircleAdc2()<br>{<br>    PERIPHERAL_ENABLE(DMAC, 0);<br>    DMAC_Init();<\/p>\n\n\n\n<p>    ADC_SetSeqLength(ADC0, ADC_SEQ_LENGTH2); \/\/ \u8bbe\u7f6eDMA\u8981\u8bfb\u53d6\u7684ADC\u7684channal\u6570<br>    ADC_SetSeqChannel(ADC0, 0, ADC_CHANNEL3); \/\/ channal-A\uff0c\u914d\u7f6e\u7b2c\u4e00\u4e2achannal\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570seq\u51b3\u5b9adma\u8bfb\u5b8c\u540e\u653e\u5230 adc_table \u7684\u54ea\u4e2a\u4f4d\u7f6e\u3002<br>    ADC_SetSeqChannel(ADC0, 1, ADC_CHANNEL4); \/\/ channal-B\uff0c\u914d\u7f6e\u7b2c\u4e8c\u4e2achannal<\/p>\n\n\n\n<p>    DMAC_ConfigCircular(DMAC_CHANNEL1, \/\/DMA\u7684channal\uff08\u8ddfADC\u7684channal\u65e0\u5173\uff09<br>        (uint32_t)&amp;ADC0->DATA, \/\/\u4ece\u54ea\u4e2aADC\u8bfb\u53d6<br>        (uint32_t)adc_table, \/\/\u5b58\u653e\u6570\u636e\u7684\u6570\u7ec4<br>        DMAC_ADDR_INCR_OFF, DMAC_ADDR_INCR_ON,<br>        DMAC_WIDTH_32_BIT, DMAC_WIDTH_32_BIT, \/\/32\u4f4d\u7684\uff0c\u4e0d\u80fd\u662f16\u4f4d<br>        DMAC_BURST_1, DMAC_BURST_1,<br>        2, \/\/\u4e00\u8f6e\u8bfb\u53d6\u51e0\u4e2a\u3002\u8ddf\u4e0a\u8fb9\u7684channal\u6570\u5bf9\u5e94\u3002<br>        DMAC_PERIPHERAL_TO_MEM_DMA_CTRL, ADC0_DMA_REQ, 0,<br>        &amp;circular_lli); \/\/lli\uff0c\u6ce8\u610f\u8fd9\u91cc\u8981\u52a0\u53d6\u503c\u7b26&amp;<br>    ADC_StartDma(ADC0, sclk_div); \/\/\u5f00\u542fDMA<\/p>\n\n\n\n<p>    while(1)<br>    {<br>        printf(\"adc value:%d, %d\\r\\n\", adc_table[0], adc_table[1]);<br>        UTIL_IdleUs(200e3);<br>    }<br>}<\/p>\n\n\n\n<p>\/\/ \u6ca1\u6709\u4f7f\u7528 DMAC_ConfigCircular \u51fd\u6570\u3002<br>\/\/ \u8fd9\u91cc\u7684\u914d\u7f6e\u65b9\u6cd5\uff0c\u548c\u4e0a\u8fb9\u7684\u51fd\u6570\u662f\u4e00\u81f4\u7684\u3002\u6ce8\u91ca\u90e8\u5206\u53c2\u8003\u4e0a\u8fb9\u7684\u51fd\u6570\u3002<br>void TestCircleAdc()<br>{<br>    PERIPHERAL_ENABLE(DMAC, 0);<br>    DMAC_Init();<\/p>\n\n\n\n<p>    ADC_SetSeqLength(ADC0, ADC_SEQ_LENGTH2); \/\/ Scan channels number<br>    ADC_SetSeqChannel(ADC0, 0, ADC_CHANNEL3); \/\/ channal-A<br>    ADC_SetSeqChannel(ADC0, 1, ADC_CHANNEL4); \/\/ channal-B<\/p>\n\n\n\n<p>    circular_lli.SrcAddr = (uint32_t)&amp;ADC0->DATA;<br>    circular_lli.DstAddr = (uint32_t)adc_table;<br>    circular_lli.LLI = (uint32_t)&amp;circular_lli; \/\/ Points to itself for circular transfer<br>    circular_lli.Control = DMAC_MakeControl(DMAC_ADDR_INCR_OFF, DMAC_ADDR_INCR_ON,<br>    DMAC_WIDTH_32_BIT, DMAC_WIDTH_32_BIT, DMAC_BURST_1, DMAC_BURST_1, 2, DISABLE);<br>    DMAC_ConfigLLI(DMAC_CHANNEL1, DMAC_PERIPHERAL_TO_MEM_DMA_CTRL, ADC0_DMA_REQ, 0, (uint32_t)&amp;circular_lli);<\/p>\n\n\n\n<p>    ADC_StartDma(ADC0, sclk_div);<\/p>\n\n\n\n<p>    while(1)<br>    {<br>        printf(\"adc value:%d, %d\\r\\n\", adc_table[0], adc_table[1]);<br>        UTIL_IdleUs(200e3);<br>    }<br>}<\/p>\n\n\n\n<p>#endif<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/example_adc_circle.c #ifdef IPS_ANALOG_IP #include \"e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","footnotes":""},"class_list":["post-874","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=874"}],"version-history":[{"count":3,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/874\/revisions"}],"predecessor-version":[{"id":877,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/874\/revisions\/877"}],"up":[{"embeddable":true,"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"http:\/\/www.agm-support.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}