﻿{"id":91,"date":"2010-05-22T09:21:06","date_gmt":"2010-05-22T01:21:06","guid":{"rendered":"http:\/\/nick.workao.org\/?p=91"},"modified":"2010-05-22T09:21:13","modified_gmt":"2010-05-22T01:21:13","slug":"stm32-%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b-%e5%9f%ba%e4%ba%8e-dma-%e7%9a%84-adc","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/scm\/91","title":{"rendered":"STM32 \u5165\u95e8\u6559\u7a0b \u57fa\u4e8e DMA \u7684 ADC"},"content":{"rendered":"<p><strong><span style=\"color: red;\">(\u4e00) STM32 ADC \u6a21\u5757\u4ecb\u7ecd\n<\/span><\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012106Cto.gif\" border=\"0\" alt=\"\" \/> <img decoding=\"async\" id=\"aimg_589\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012108luA.jpg\" alt=\"2.jpg\" width=\"600\" \/><\/p>\n<p><a title=\"2.jpg\" href=\"http:\/\/www.mystm32.com\/bbs\/attachment.php?aid=589&#038;k=71cecd356a008fdfa64555b061330ba0&#038;t=1257839459&#038;nothumb=yes&#038;sid=fe20hRSmRZ5wxUbuvdLY6GbwrUQxRec1GWUnBXAG%2B%2F7IGPk\" target=\"_blank\"><strong>\u4e0b\u8f7d<\/strong><\/a> (52.26 KB)<\/p>\n<div>2009-8-21 23:41<\/div>\n<p><img decoding=\"async\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012106Cto.gif\" border=\"0\" alt=\"\" \/> <img decoding=\"async\" id=\"aimg_590\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012110Kaz.jpg\" alt=\"1.jpg\" width=\"600\" \/><\/p>\n<p><a title=\"1.jpg\" href=\"http:\/\/www.mystm32.com\/bbs\/attachment.php?aid=590&#038;k=af94f607bfee741455744e3ae8f47a9b&#038;t=1257839459&#038;nothumb=yes&#038;sid=fe20hRSmRZ5wxUbuvdLY6GbwrUQxRec1GWUnBXAG%2B%2F7IGPk\" target=\"_blank\"><strong>\u4e0b\u8f7d<\/strong><\/a> (69.24 KB)<\/p>\n<div>2009-8-21 23:41<\/div>\n<p><strong><span style=\"color: red;\">(\u4e8c) \u7a0b\u5e8f\u7f16\u5199\n<\/span><\/strong>\n<span style=\"color: purple;\">(1) \u8bbe\u7f6e ADC \u7684\u5730\u5740\n<\/span>\n<span style=\"font-size: x-small;\">#define ADC1_DR_Address\u00a0 \u00a0 ((u32)0x4001244C)<\/p>\n<p><span style=\"color: purple;\">(2) \u521d\u59cb\u5316 DMA \u548c ADC \u6a21\u5757\u4e0e\u5e94\u7528\u7a0b\u5e8f\n<\/span>\/<em> DMA channel1 configuration  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em>\/\nDMA_DeInit(DMA1_Channel1);\nDMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;\u00a0\u00a0\/\/ \u5916\u8bbe\u5730\u5740\nDMA_InitStructure.DMA_MemoryBaseAddr = (u32)&#038;ADC_ConvertedValue; \/\/  \u5185\u5b58\u5730\u5740\nDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;\u00a0\u00a0\/\/ DMA \u4f20\u8f93\u65b9\u5411\u5355\u5411\nDMA_InitStructure.DMA_BufferSize = 1;\u00a0 \u00a0\/\/ \u8bbe\u7f6eDMA\u5728\u4f20\u8f93\u65f6\u7f13\u51b2\u533a\u7684\u957f\u5ea6 word\nDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;  \/\/\u8bbe\u7f6eDMA\u5916\u8bbe\u9012\u589e\u6a21\u5f0f\nDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; \/\/ \u8bbe\u7f6eDMA\u5185\u5b58\u9012\u589e\u6a21\u5f0f\nDMA_InitStructure.DMA_PeripheralDataSize =  DMA_PeripheralDataSize_HalfWord;\u00a0\u00a0\/\/ \u5916\u8bbe\u6570\u636e\u5b57\u957f\nDMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;  \/\/\u5185\u5b58\u6570\u636e\u5b57\u957f\nDMA_InitStructure.DMA_Mode = DMA_Mode_Circular;\u00a0\u00a0\/\/ \u8bbe\u7f6e\u4f20\u8f93\u6a21\u5f0f\u8fde\u7eed\u4e0d\u65ad\u7684\u5faa\u73af\u6a21\u5f0f\nDMA_InitStructure.DMA_Priority = DMA_Priority_High; \/\/ \u8bbe\u7f6eDMA\u7684\u4f18\u5148\u7ea7\u522b\nDMA_InitStructure.DMA_M2M = DMA_M2M_Disable; \/\/ \u8bbe\u7f6eDMA\u76842\u4e2amemory\u4e2d\u7684\u53d8\u91cf\u4e92\u76f8\u8bbf\u95ee\nDMA_Init(DMA1_Channel1, &#038;DMA_InitStructure);<\/p>\n<p>\/<em> Enable DMA channel1 <\/em>\/\nDMA_Cmd(DMA1_Channel1, ENABLE);<\/p>\n<p>\/<em> ADC1 configuration  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/em>\/\nADC_InitStructure.ADC_Mode = ADC_Mode_Independent;\u00a0 \u00a0\/\/ \u72ec\u7acb\u5de5\u4f5c\u6a21\u5f0f\nADC_InitStructure.ADC_ScanConvMode = ENABLE;\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\/\/ \u626b\u63cf\u65b9\u5f0f\nADC_InitStructure.ADC_ContinuousConvMode = ENABLE;\u00a0 \u00a0\/\/ \u8fde\u7eed\u8f6c\u6362\nADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; \/\/  \u5916\u90e8\u89e6\u53d1\u7981\u6b62\nADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\/\/  \u6570\u636e\u53f3\u5bf9\u9f50\nADC_InitStructure.ADC_NbrOfChannel = 1;\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\/\/ \u7528\u4e8e\u8f6c\u6362\u7684\u901a\u9053\u6570\nADC_Init(ADC1, &#038;ADC_InitStructure);<\/p>\n<p>\/<em> ADC1 regular channel14 configuration <\/em>\/\nADC_RegularChannelConfig(ADC1, ADC_Channel_2, 1,  ADC_SampleTime_55Cycles5);<\/p>\n<p>\/<em> Enable ADC1 DMA <\/em>\/\nADC_DMACmd(ADC1, ENABLE);<\/p>\n<p>\/<em> Enable ADC1 <\/em>\/\nADC_Cmd(ADC1, ENABLE);<\/p>\n<p>\/<em> Enable ADC1 reset calibaration register <\/em>\/\nADC_ResetCalibration(ADC1);\n\/<em> Check the end of ADC1 reset calibration register <\/em>\/\nwhile(ADC_GetResetCalibrationStatus(ADC1));<\/p>\n<p>\/<em> Start ADC1 calibaration <\/em>\/\nADC_StartCalibration(ADC1);\n\/<em> Check the end of ADC1 calibration <\/em>\/\nwhile(ADC_GetCalibrationStatus(ADC1));<\/p>\n<p>\/<em> Start ADC1 Software Conversion <\/em>\/\nADC_SoftwareStartConvCmd(ADC1, ENABLE);<\/p>\n<p>while(1)\n{\nAD_value = ADC_GetConversionValue(ADC1);<\/p>\n<p>delay();\n}<\/span><\/p>\n<p><strong><span style=\"color: red;\">(\u4e09) \u4eff\u771f\u8c03\u8bd5<\/span><\/strong><\/p>\n<p>(1) \u4f7f\u7528Keil uVision3 \u901a\u8fc7ULINK 2<\/p>\n<p>\u4eff\u771f\u5668<\/p>\n<p>\u8fde\u63a5\u5b9e\u9a8c\u677f\uff0c\u4f7f\u7528MINI-STM32 \u5f00\u53d1\u677f\u9644\u5e26\u7684\u4e32\u53e3\u7ebf\uff0c\u8fde\u63a5\u5b9e\u9a8c\u677f\u4e0a\u7684 UART1 \u548c PC  \u673a\u7684\u4e32\u53e3\uff0c\u6253\u5f00\u5b9e\u9a8c\u4f8b\u7a0b\u76ee\u5f55\u4e0b\u7684ADC.Uv2\u4f8b\u7a0b\uff0c\u7f16\u8bd1<\/p>\n<p>\u94fe\u63a5<\/p>\n<p>\u5de5\u7a0b\uff1b<\/p>\n<p>(2) \u5728 PC \u673a\u4e0a\u8fd0\u884c windows  \u81ea\u5e26\u7684\u8d85\u7ea7\u7ec8\u7aef\u4e32\u53e3\u901a\u4fe1\u7a0b\u5e8f\uff08\u6ce2\u7279\u7387115200\u30011\u4f4d\u505c\u6b62\u4f4d\u3001\u65e0\u6821\u9a8c\u4f4d\u3001\u65e0\u786c\u4ef6\u6d41\u63a7\u5236\uff09\uff1b\u6216\u8005\u4f7f\u7528\u5176\u5b83\u4e32\u53e3\u901a\u4fe1\u7a0b\u5e8f\uff1b<\/p>\n<p>(3) \u70b9\u51fb<\/p>\n<p>MDK<\/p>\n<p>\u7684Debug\u83dc\u5355\uff0c\u70b9\u51fbStart\/Stop Debug Session\uff1b<\/p>\n<p>(4) \u65cb\u8f6c\u7535\u4f4d\u5668 R19\uff0c\u53ef\u4ee5\u770b\u5230\u4e32\u53e3\u8f93\u51fa\u6570\u503c\u4e0d\u65ad\u53d8\u5316\uff0c\u6b63\u5e38\u663e\u793a\u7ed3\u679c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p>usart1 print AD_value &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>The current AD value = 0x0425<\/p>\n<p>The current AD value = 0x0423<\/p>\n<p>The current AD value = 0x0421<\/p>\n<p>The current AD value = 0x0422<\/p>\n<p>The current AD value = 0x0420<\/p>\n<p>The current AD value = 0x0416<\/p>\n<p>The current AD value = 0x03B6<\/p>\n<p>The current AD value = 0x0841<\/p>\n<p>The current AD value = 0x08C3<\/p>\n<p>The current AD value = 0x08C0<\/p>\n<p>The current AD value = 0x08BE<\/p>\n<p>The current AD value = 0x09E9<\/p>\n<p>The current AD value = 0x0A12<\/p>\n<p>The current AD value = 0x0ACA<\/p>\n<p>The current AD value = 0x0B0D<\/p>\n<p>The current AD value = 0x0B10<\/p>\n<p>The current AD value = 0x0B0E<\/p>\n<p>&#8230;.<\/p>\n<p>&#8230;.<\/p>\n<p>(5) \u82e5\u65e0\u5f00\u53d1\u677f\uff0c\u8bfb\u8005\u4e5f\u53ef\u4ee5\u4f7f\u7528<\/p>\n<p>\u8f6f\u4ef6<\/p>\n<p>\u4eff\u771f\u6a21\u5f0f\u6765\u5b8c\u6210\u7a0b\u5e8f\u8fd0\u884c\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012106Cto.gif\" border=\"0\" alt=\"\" \/> <img decoding=\"async\" id=\"aimg_591\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2010\/05\/012112bAI.jpg\" alt=\"1.jpg\" width=\"509\" \/><\/p>\n<p><a title=\"1.jpg\" href=\"http:\/\/www.mystm32.com\/bbs\/attachment.php?aid=591&#038;k=b11dfd0902d031b46d261199807d4a10&#038;t=1257839459&#038;nothumb=yes&#038;sid=fe20hRSmRZ5wxUbuvdLY6GbwrUQxRec1GWUnBXAG%2B%2F7IGPk\" target=\"_blank\"><strong>\u4e0b<\/strong><\/a>(77.9 KB)<\/p>\n<div>2009-8-21 23:54<\/div>","protected":false},"excerpt":{"rendered":"<p>(\u4e00) STM32 ADC \u6a21\u5757\u4ecb\u7ecd \u4e0b\u8f7d (52.26 KB) 2009-8-21 23:41 \u4e0b\u8f7d (69.24 KB) 2009-8-21 23:41 (\u4e8c) \u7a0b\u5e8f\u7f16\u5199 (1) \u8bbe\u7f6e ADC \u7684&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[55,54,41,46,51],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-scm","tag-adc","tag-dma","tag-stm32","tag-46","tag-51"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":1,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":92,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/91\/revisions\/92"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}