{"id":72101,"date":"2026-02-04T22:18:16","date_gmt":"2026-02-04T14:18:16","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/72101.html"},"modified":"2026-02-04T22:18:16","modified_gmt":"2026-02-04T14:18:16","slug":"stm32-dma%e6%95%b0%e6%8d%ae%e8%bd%ac%e6%8d%a2%e3%80%81dmaad%e5%a4%9a%e9%80%9a%e9%81%93%ef%bc%88%e5%8d%81%e4%ba%94%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/72101.html","title":{"rendered":"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09"},"content":{"rendered":"<h3>\u4e00\u3001\u5e93\u51fd\u6570<\/h3>\n<p>1\u3001void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u914d\u7f6e DMA \u901a\u9053\u7684\u4e2d\u65ad\u4f7f\u80fd \/ \u5931\u80fd&#xff08;\u5f00\u542f\u6216\u5173\u95ed\u67d0\u4e2a DMA \u4e2d\u65ad\u7c7b\u578b&#xff09;\u3002<\/p>\n<p>2\u3001void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u8bbe\u7f6e DMA \u901a\u9053\u7684\u5f53\u524d\u5269\u4f59\u4f20\u8f93\u6570\u636e\u4e2a\u6570&#xff08;DMA \u7684\u6838\u5fc3\u8ba1\u6570\u5668&#xff0c;\u4f20\u8f93 1 \u4e2a\u6570\u636e&#xff0c;\u8ba1\u6570\u5668\u81ea\u52a8\u51cf 1&#xff09;\u3002<\/p>\n<p>3\u3001uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u83b7\u53d6 DMA \u901a\u9053\u7684\u5f53\u524d\u5269\u4f59\u4f20\u8f93\u6570\u636e\u4e2a\u6570&#xff08;\u8bfb\u53d6\u8ba1\u6570\u5668\u7684\u5b9e\u65f6\u503c&#xff09;&#xff0c;\u8fd4\u56de\u503c\u4e3a\u5269\u4f59\u4e2a\u6570\u3002<\/p>\n<p>4\u3001FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u67e5\u8be2 DMA \u7684\u72b6\u6001\u6807\u5fd7\u4f4d\u662f\u5426\u7f6e 1&#xff08;\u5373\u67d0\u4e2a\u4e8b\u4ef6\u662f\u5426\u53d1\u751f&#xff0c;\u5982\u4f20\u8f93\u5b8c\u6210\u3001\u534a\u4f20\u8f93\u3001\u9519\u8bef&#xff09;&#xff0c;\u8fd4\u56de\u6807\u5fd7\u4f4d\u72b6\u6001\u3002<\/p>\n<p>5\u3001void DMA_ClearFlag(uint32_t DMAy_FLAG)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u624b\u52a8\u6e05\u9664 DMA \u7684\u72b6\u6001\u6807\u5fd7\u4f4d&#xff08;\u5c06\u7f6e 1 \u7684\u6807\u5fd7\u4f4d\u6e05\u96f6&#xff09;\u3002<\/p>\n<p>6\u3001ITStatus DMA_GetITStatus(uint32_t DMAy_IT)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u67e5\u8be2 DMA \u7684\u4e2d\u65ad\u6302\u8d77\u4f4d\u662f\u5426\u7f6e 1&#xff08;\u5373\u67d0\u4e2a\u4e2d\u65ad\u4e8b\u4ef6\u662f\u5426\u53d1\u751f&#xff0c;\u4e14\u8be5\u4e2d\u65ad\u5df2\u5f00\u542f&#xff09;&#xff0c;\u8fd4\u56de\u4e2d\u65ad\u72b6\u6001\u3002<\/p>\n<p>7\u3001void DMA_ClearITPendingBit(uint32_t DMAy_IT)<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;\u6e05\u9664 DMA \u7684\u4e2d\u65ad\u6302\u8d77\u4f4d&#xff08;\u5c06\u7f6e 1 \u7684\u4e2d\u65ad\u6302\u8d77\u4f4d\u6e05\u96f6&#xff09;\u3002<\/p>\n<h3>\u4e8c\u3001\u6570\u636e\u8f6c\u6362<\/h3>\n<p>\u5c06\u6570\u7ec4A\u4e2d\u7684\u6570\u636e\u8f6c\u6362\u5230\u6570\u7ec4B\u4e2d<\/p>\n<p>uint8_t DataA[] &#061; {0x01, 0x02, 0x03, 0x04};<br \/>\nuint8_t DataB[] &#061; {0, 0, 0, 0};<\/p>\n<h5>1\u3001\u521d\u59cb\u5316\u914d\u7f6e<\/h5>\n<p>void MyDMA_Init(uint32_t AddrA, uint32_t AddrB, uint16_t Size)<br \/>\n{<br \/>\nMyDMA_Size &#061; Size;<br \/>\nRCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);<br \/>\nDMA_InitTypeDef DMA_InitStructure;<br \/>\nDMA_InitStructure.DMA_PeripheralBaseAddr &#061; AddrA;<br \/>\nDMA_InitStructure.DMA_PeripheralDataSize &#061; DMA_PeripheralDataSize_Byte;<br \/>\nDMA_InitStructure.DMA_PeripheralInc &#061; DMA_PeripheralInc_Enable;<br \/>\nDMA_InitStructure.DMA_MemoryBaseAddr &#061; AddrB;<br \/>\nDMA_InitStructure.DMA_MemoryDataSize &#061; DMA_MemoryDataSize_Byte;<br \/>\nDMA_InitStructure .DMA_MemoryInc &#061; DMA_MemoryInc_Enable;<br \/>\nDMA_InitStructure.DMA_DIR &#061; DMA_DIR_PeripheralSRC;<br \/>\nDMA_InitStructure.DMA_BufferSize &#061; Size;<br \/>\nDMA_InitStructure.DMA_Mode &#061; DMA_Mode_Normal;<br \/>\nDMA_InitStructure.DMA_M2M &#061; DMA_M2M_Enable;<br \/>\nDMA_InitStructure.DMA_Priority &#061; DMA_Priority_Medium;<br \/>\nDMA_Init(DMA1_Channel1,&amp;DMA_InitStructure);<\/p>\n<p>DMA_Cmd(DMA1_Channel1,DISABLE);<br \/>\n}<\/p>\n<p>\u7ad9\u70b9\u5730\u5740<\/p>\n<p>\u5c06\u8981\u8f6c\u6362\u6570\u7ec4\u7684\u5730\u5740\u548c\u6570\u636e\u4e2a\u6570\u4f20\u5165\u3002<\/p>\n<p>void MyDMA_Init(uint32_t AddrA, uint32_t AddrB, uint16_t Size)<\/p>\n<p>\u6253\u5f00DMA\u65f6\u949f<\/p>\n<p>\u00a0RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);<\/p>\n<p>\u914d\u7f6e\u5916\u8bbe\u7ad9\u70b9<\/p>\n<p>\u914d\u7f6e\u5916\u8bbe\u7ad9\u70b9\u5730\u5740&#xff0c;\u6570\u636e\u5bbd\u5ea6&#xff1a;\u4ee5\u5b57\u8282\u4f20\u8f93&#xff0c;\u5730\u5740\u662f\u5426\u81ea\u589e&#xff1a;\u662f\u3002<\/p>\n<p>   \u00a0DMA_InitStructure.DMA_PeripheralBaseAddr &#061; AddrA;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_PeripheralDataSize &#061; DMA_PeripheralDataSize_Byte;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_PeripheralInc &#061; DMA_PeripheralInc_Enable;<\/p>\n<p>\u914d\u7f6e\u5b58\u50a8\u5668\u7ad9\u70b9<\/p>\n<p>\u914d\u7f6e\u5b58\u50a8\u5668\u7ad9\u70b9\u5730\u5740&#xff0c;\u6570\u636e\u5bbd\u5ea6&#xff1a;\u4ee5\u5b57\u8282\u4f20\u8f93&#xff0c;\u5730\u5740\u662f\u5426\u81ea\u589e&#xff1a;\u662f\u3002<\/p>\n<p>    DMA_InitStructure.DMA_MemoryBaseAddr &#061; AddrB;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_MemoryDataSize &#061; DMA_MemoryDataSize_Byte;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure .DMA_MemoryInc &#061; DMA_MemoryInc_Enable;<\/p>\n<p>\u914d\u7f6e\u4f20\u8f93\u65b9\u5411\u548c\u6570\u636e\u4e2a\u6570<\/p>\n<p>\u914d\u7f6e\u4e3a\u4ece\u5916\u90e8\u7ad9\u70b9\u4f20\u8f93\u5230\u5b58\u50a8\u5668\u7ad9\u70b9&#xff0c;\u6570\u636e\u4e2a\u6570Size\u3002<\/p>\n<p>    DMA_InitStructure.DMA_DIR &#061; DMA_DIR_PeripheralSRC;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_BufferSize &#061; Size;<\/p>\n<p>\u914d\u7f6e\u91cd\u88c5&#xff0c;\u89e6\u53d1\u3001\u4f18\u5148\u7ea7<\/p>\n<p>\u914d\u7f6e\u4e3a\u4e0d\u91cd\u88c5&#xff0c;\u8f6f\u4ef6\u89e6\u53d1&#xff0c;\u4e2d\u7b49\u4f18\u5148\u7ea7&#xff08;\u5728\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\u53ef\u4efb\u610f\u914d\u7f6e&#xff09;<\/p>\n<p>    DMA_InitStructure.DMA_Mode &#061; DMA_Mode_Normal;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_M2M &#061; DMA_M2M_Enable;<br \/>\n\u00a0\u00a0 \u00a0DMA_InitStructure.DMA_Priority &#061; DMA_Priority_Medium;<\/p>\n<p>\u5173\u95edDMA1<\/p>\n<p>\u00a0\u00a0 \u00a0DMA_Cmd(DMA1_Channel1,DISABLE);<\/p>\n<h5>2\u3001\u518d\u6b21\u542f\u52a8DMA<\/h5>\n<p>\u5f53\u6570\u7ec4A\u7684\u6570\u636e\u53d8\u5316\u540e&#xff0c;\u518d\u6b21\u542f\u52a8DMA\u8f6c\u6362\u6570\u636e\u5230\u6570\u7ec4B\u3002<\/p>\n<p>void MyDMA_Transfer(void)<br \/>\n{<br \/>\nDMA_Cmd(DMA1_Channel1,DISABLE);<br \/>\nDMA_SetCurrDataCounter(DMA1_Channel1,MyDMA_Size);<br \/>\nDMA_Cmd(DMA1_Channel1,ENABLE);<\/p>\n<p>while(DMA_GetFlagStatus(DMA1_FLAG_TC1) &#061;&#061; RESET);<br \/>\nDMA_ClearFlag(DMA1_FLAG_TC1);<br \/>\n}<\/p>\n<p>\u518d\u6b21\u542f\u52a8DMA\u8981\u91cd\u88c5\u8ba1\u6570\u5668&#xff0c;\u91cd\u88c5\u8ba1\u6570\u5668\u8981\u5148\u5173\u95edDMA&#xff0c;MyDMA_Size\u5728\u524d\u9762Init \u4e2d\u6709\u88ab\u6267\u884cMyDMA_Size &#061;\u00a0Size&#xff1b;<\/p>\n<p>    DMA_Cmd(DMA1_Channel1,DISABLE);<br \/>\nDMA_SetCurrDataCounter(DMA1_Channel1,MyDMA_Size);<br \/>\nDMA_Cmd(DMA1_Channel1,ENABLE);<\/p>\n<p>\u7b49\u5f85DMA\u901a\u90531\u8f6c\u6362\u5b8c\u6210\u6807\u5fd7\u4f4d\u7f6e1&#xff0c;\u7136\u540e\u624b\u52a8\u6e05\u9664\u6807\u5fd7\u4f4d\u3002<\/p>\n<p>    while(DMA_GetFlagStatus(DMA1_FLAG_TC1) &#061;&#061; RESET);<br \/>\nDMA_ClearFlag(DMA1_FLAG_TC1);<\/p>\n<h5>3\u3001\u8c03\u7528<\/h5>\n<p>\u8ba9\u6570\u7ec4A\u7684\u5143\u7d20&#043;&#043;&#xff0c;\u663e\u793a\u4e24\u4e2a\u6570\u7ec4\u7684\u5143\u7d20\u503c&#xff0c;\u5ef6\u65f6\u4e00\u6bb5\u65f6\u95f4&#xff0c;\u7136\u540e\u5728\u663e\u793a\u66f4\u65b0\u540e\u7684\u503c\u3002<\/p>\n<p>int main(void)<br \/>\n{<br \/>\nOLED_Init();<\/p>\n<p>MyDMA_Init((uint32_t)DataA,(uint32_t)DataB,4);<\/p>\n<p>OLED_ShowString(1,1,&#034;DataA&#034;);<br \/>\nOLED_ShowString(3,1,&#034;DataB&#034;);<br \/>\nOLED_ShowHexNum(1,8,(uint32_t)DataA,8);<br \/>\nOLED_ShowHexNum(3,8,(uint32_t)DataB,8);<\/p>\n<p>OLED_ShowHexNum(2,1,DataA[0],2);<br \/>\nOLED_ShowHexNum(2,4,DataA[1],2);<br \/>\nOLED_ShowHexNum(2,7,DataA[2],2);<br \/>\nOLED_ShowHexNum(2,10,DataA[3],2);<br \/>\nOLED_ShowHexNum(4,1,DataB[0],2);<br \/>\nOLED_ShowHexNum(4,4,DataB[1],2);<br \/>\nOLED_ShowHexNum(4,7,DataB[2],2);<br \/>\nOLED_ShowHexNum(4,10,DataB[3],2);<\/p>\n<p>while(1)<br \/>\n{<br \/>\nDataA[0] &#043;&#043;;<br \/>\nDataA[1] &#043;&#043;;<br \/>\nDataA[2] &#043;&#043;;<br \/>\nDataA[3] &#043;&#043;;<\/p>\n<p>OLED_ShowHexNum(2,1,DataA[0],2);<br \/>\nOLED_ShowHexNum(2,4,DataA[1],2);<br \/>\nOLED_ShowHexNum(2,7,DataA[2],2);<br \/>\nOLED_ShowHexNum(2,10,DataA[3],2);<br \/>\nOLED_ShowHexNum(4,1,DataB[0],2);<br \/>\nOLED_ShowHexNum(4,4,DataB[1],2);<br \/>\nOLED_ShowHexNum(4,7,DataB[2],2);<br \/>\nOLED_ShowHexNum(4,10,DataB[3],2);<\/p>\n<p>Delay_ms(1000);<\/p>\n<p>MyDMA_Transfer();<br \/>\nOLED_ShowHexNum(2,1,DataA[0],2);<br \/>\nOLED_ShowHexNum(2,4,DataA[1],2);<br \/>\nOLED_ShowHexNum(2,7,DataA[2],2);<br \/>\nOLED_ShowHexNum(2,10,DataA[3],2);<br \/>\nOLED_ShowHexNum(4,1,DataB[0],2);<br \/>\nOLED_ShowHexNum(4,4,DataB[1],2);<br \/>\nOLED_ShowHexNum(4,7,DataB[2],2);<br \/>\nOLED_ShowHexNum(4,10,DataB[3],2);<\/p>\n<p>Delay_ms(1000);<br \/>\n}<br \/>\n}<\/p>\n<h3>\u4e09\u3001DMA&#043;AD\u591a\u901a\u9053<\/h3>\n<h5>1\u3001\u63a5\u7ebf\u56fe<\/h5>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"435\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204141815-698355272595e.png\" width=\"600\" \/><\/p>\n<h5>2\u3001\u521d\u59cb\u5316\u914d\u7f6e<\/h5>\n<p>\u914d\u7f6eADC&#xff1a;\u5355ADC\u5de5\u4f5c\u3001\u6570\u636e\u53f3\u5bf9\u9f50\u3001\u8f6f\u4ef6\u89e6\u53d1\u3001\u5173\u95ed\u8fde\u7eed\u8f6c\u6362\u3001\u626b\u63cf\u6a21\u5f0f\u3001\u626b\u63cf\u901a\u9053\u6570\u76ee4<\/p>\n<p>\u914d\u7f6eDMA&#xff1a;<\/p>\n<p>\u5916\u90e8\u7ad9\u70b9&#xff1a;\u5730\u5740\u662fADC1\u7684DR\u5bc4\u5b58\u5668&#xff08;ADC\u8f6c\u5316\u7ed3\u679c\u5b58\u653e\u5728\u8fd9\u4e2a\u5bc4\u5b58\u5668&#xff09;\u3001\u6570\u636e\u5e26\u5bbd16\u4f4d\u3001\u5730\u5740\u4e0d\u9012\u589e\u3002<\/p>\n<p>\u5b58\u50a8\u5668\u7ad9\u70b9&#xff1a;\u5730\u5740\u662f\u5168\u5c40\u6570\u7ec4AD_Value\u3001\u6570\u636e\u5e26\u5bbd16\u4f4d\u3001\u5730\u5740\u9012\u589e\u3002<\/p>\n<p>\u642c\u8fd0\u65b9\u5411\u5916\u8bbe\u2192\u5185\u5b58\u3001\u642c\u8fd0\u6b21\u65704\u6b21\u3001\u5355\u6b21\u642c\u8fd0\u3001ADC\u786c\u4ef6\u89e6\u53d1\u3001DMA\u4f18\u5148\u7ea7&#xff1a;\u4e2d\u7b49&#xff08;\u65e0\u5176\u4ed6DMA\u65f6\u968f\u610f&#xff09;<\/p>\n<p>void AD_Init(void)<br \/>\n{<br \/>\nRCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);<br \/>\nRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);<br \/>\nRCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);<\/p>\n<p>RCC_ADCCLKConfig(RCC_PCLK2_Div6);<\/p>\n<p>GPIO_InitTypeDef GPIO_Initstructure;<br \/>\nGPIO_Initstructure.GPIO_Mode &#061; GPIO_Mode_AIN;\/\/\u6b64\u65f6GPIO\u53e3\u53ea\u53d7\u5230ADC\u7684\u63a7\u5236<br \/>\nGPIO_Initstructure.GPIO_Pin &#061; GPIO_Pin_0 | GPIO_Pin_1| GPIO_Pin_2 | GPIO_Pin_3;<br \/>\nGPIO_Initstructure.GPIO_Speed &#061; GPIO_Speed_50MHz;<br \/>\nGPIO_Init(GPIOA,&amp;GPIO_Initstructure);<\/p>\n<p>ADC_RegularChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_55Cycles5);<br \/>\nADC_RegularChannelConfig(ADC1,ADC_Channel_1,2,ADC_SampleTime_55Cycles5);<br \/>\nADC_RegularChannelConfig(ADC1,ADC_Channel_2,3,ADC_SampleTime_55Cycles5);<br \/>\nADC_RegularChannelConfig(ADC1,ADC_Channel_3,4,ADC_SampleTime_55Cycles5);<\/p>\n<p>ADC_InitTypeDef ADC_InitStructure;<br \/>\nADC_InitStructure.ADC_Mode &#061; ADC_Mode_Independent;<br \/>\nADC_InitStructure.ADC_DataAlign &#061; ADC_DataAlign_Right;<br \/>\nADC_InitStructure.ADC_ExternalTrigConv &#061; ADC_ExternalTrigConv_None;<br \/>\nADC_InitStructure.ADC_ContinuousConvMode &#061; DISABLE;<br \/>\nADC_InitStructure.ADC_ScanConvMode &#061; ENABLE;<br \/>\nADC_InitStructure.ADC_NbrOfChannel &#061; 4;<br \/>\nADC_Init(ADC1,&amp;ADC_InitStructure);<\/p>\n<p>DMA_InitTypeDef DMA_InitStructure;<br \/>\nDMA_InitStructure.DMA_PeripheralBaseAddr &#061; (uint32_t)&amp;ADC1-&gt;DR;<br \/>\nDMA_InitStructure.DMA_PeripheralDataSize &#061; DMA_PeripheralDataSize_HalfWord;<br \/>\nDMA_InitStructure.DMA_PeripheralInc &#061; DMA_PeripheralInc_Disable;<br \/>\nDMA_InitStructure.DMA_MemoryBaseAddr &#061; (uint32_t)AD_Value;<br \/>\nDMA_InitStructure.DMA_MemoryDataSize &#061; DMA_MemoryDataSize_HalfWord;<br \/>\nDMA_InitStructure.DMA_MemoryInc &#061; DMA_MemoryInc_Enable;<br \/>\nDMA_InitStructure.DMA_DIR &#061; DMA_DIR_PeripheralSRC;<br \/>\nDMA_InitStructure.DMA_BufferSize &#061; 4;<br \/>\nDMA_InitStructure.DMA_Mode &#061; DMA_Mode_Normal;<br \/>\nDMA_InitStructure.DMA_M2M &#061; DMA_M2M_Disable;<br \/>\nDMA_InitStructure.DMA_Priority &#061; DMA_Priority_Medium;<br \/>\nDMA_Init(DMA1_Channel1,&amp;DMA_InitStructure);<\/p>\n<p>DMA_Cmd(DMA1_Channel1,ENABLE);<\/p>\n<p>ADC_DMACmd(ADC1, ENABLE);<br \/>\nADC_Cmd(ADC1,ENABLE);<\/p>\n<p>ADC_ResetCalibration(ADC1);<br \/>\nwhile(ADC_GetResetCalibrationStatus(ADC1) &#061;&#061; SET);<br \/>\nADC_StartCalibration(ADC1);<br \/>\nwhile(ADC_GetCalibrationStatus(ADC1) &#061;&#061; SET);<\/p>\n<p>}<\/p>\n<p>\u6253\u5f00ADC\u548cDMA\u7684\u901a\u9053<\/p>\n<p>\u5f00\u542fADC1\u7684DMA\u8bf7\u6c42&#xff08;ADC\u8f6c\u6362\u5b8c\u6210\u540e&#xff0c;\u4e3b\u52a8\u901a\u77e5DMA\u642c\u8fd0&#xff09;<\/p>\n<p>ADC_DMACmd(ADC1, ENABLE);<\/p>\n<h5>3\u3001\u518d\u542f\u52a8<\/h5>\n<p>\u9700\u8981\u91c7\u96c6\u6570\u636e\u65f6&#xff0c;\u5728\u4e3b\u51fd\u6570\u4e2d\u8c03\u7528\u4e00\u6b21\u5c31\u6267\u884c\u4e00\u6b21 4 \u901a\u9053\u626b\u63cf&#xff0c;\u91c7\u96c6\u5b8c\u6210\u540e\u7ed3\u679c\u81ea\u52a8\u5b58\u5165AD_Value\u6570\u7ec4<\/p>\n<p>void AD_GetValue(void)<br \/>\n{<br \/>\nDMA_Cmd(DMA1_Channel1,DISABLE);<br \/>\nDMA_SetCurrDataCounter(DMA1_Channel1,4);<br \/>\nDMA_Cmd(DMA1_Channel1,ENABLE);<\/p>\n<p>ADC_SoftwareStartConvCmd(ADC1,ENABLE);<br \/>\nwhile(DMA_GetFlagStatus(DMA1_FLAG_TC1) &#061;&#061; RESET);<br \/>\nDMA_ClearFlag(DMA1_FLAG_TC1);<br \/>\n}<\/p>\n<h5>4\u3001\u8c03\u7528<\/h5>\n<p>int main(void)<br \/>\n{<br \/>\nOLED_Init();<br \/>\nAD_Init();<\/p>\n<p>OLED_ShowString(1,1,&#034;AD0:&#034;);<br \/>\nOLED_ShowString(2,1,&#034;AD1:&#034;);<br \/>\nOLED_ShowString(3,1,&#034;AD2:&#034;);<br \/>\nOLED_ShowString(4,1,&#034;AD3:&#034;);<\/p>\n<p>while(1)<br \/>\n{<br \/>\nAD_GetValue();<\/p>\n<p>OLED_ShowNum(1,5,AD_Value[0],4);<br \/>\nOLED_ShowNum(2,5,AD_Value[1],4);<br \/>\nOLED_ShowNum(3,5,AD_Value[2],4);<br \/>\nOLED_ShowNum(4,5,AD_Value[3],4);<\/p>\n<p>Delay_ms(100);<\/p>\n<p>}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5e93\u51fd\u65701\u3001void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)\u6838\u5fc3\u529f\u80fd&#xff1a;\u914d\u7f6e DMA \u901a\u9053\u7684\u4e2d\u65ad\u4f7f\u80fd \/ \u5931\u80fd&#xff08;\u5f00\u542f\u6216\u5173\u95ed\u67d0\u4e2a DMA \u4e2d\u65ad\u7c7b\u578b&#xff09;\u30022\u3001void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_<\/p>\n","protected":false},"author":2,"featured_media":72100,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[217,270,269],"topic":[],"class_list":["post-72101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32","tag-270","tag-269"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/72101.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u5e93\u51fd\u65701\u3001void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)\u6838\u5fc3\u529f\u80fd&#xff1a;\u914d\u7f6e DMA \u901a\u9053\u7684\u4e2d\u65ad\u4f7f\u80fd \/ \u5931\u80fd&#xff08;\u5f00\u542f\u6216\u5173\u95ed\u67d0\u4e2a DMA \u4e2d\u65ad\u7c7b\u578b&#xff09;\u30022\u3001void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/72101.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-04T14:18:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204141815-698355272595e.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72101.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/72101.html\",\"name\":\"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-04T14:18:16+00:00\",\"dateModified\":\"2026-02-04T14:18:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/72101.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/72101.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/72101.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/72101.html","og_locale":"zh_CN","og_type":"article","og_title":"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u5e93\u51fd\u65701\u3001void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)\u6838\u5fc3\u529f\u80fd&#xff1a;\u914d\u7f6e DMA \u901a\u9053\u7684\u4e2d\u65ad\u4f7f\u80fd \/ \u5931\u80fd&#xff08;\u5f00\u542f\u6216\u5173\u95ed\u67d0\u4e2a DMA \u4e2d\u65ad\u7c7b\u578b&#xff09;\u30022\u3001void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_","og_url":"https:\/\/www.wsisp.com\/helps\/72101.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-04T14:18:16+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260204141815-698355272595e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/72101.html","url":"https:\/\/www.wsisp.com\/helps\/72101.html","name":"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-04T14:18:16+00:00","dateModified":"2026-02-04T14:18:16+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/72101.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/72101.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/72101.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"STM32\u2014\u2014DMA\u6570\u636e\u8f6c\u6362\u3001DMA+AD\u591a\u901a\u9053\uff08\u5341\u4e94\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=72101"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/72101\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/72100"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=72101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=72101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=72101"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=72101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}