你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STM32G491试用】(4) ADC内核

[复制链接]
wenyangzeng 提问时间:2021-4-11 08:41 / 已解决
【STM32G491试用】(4) ADC内核
     看到网上有网友发帖说是STM32G4系列有多个独立ADC内核,可以同步采样转换多路ADC输入信号。有点疑惑,
翻阅STM32G4用户手册,它的ADC模块框图如下,应该是只有1个ADC转换内核,多路转换器分时转换。

ADC.png

    决定使用STM32G491开发板来验证一下,使用直流源来测试没有意义,需要使用正弦波来测试。首先使用片内
DAC1通道1产生一个50HZ正弦波信号,然后分别施加到ADC1_2、ADC2_1、ADC3_5输入端,3路ADC同步使用
TIM6_TROG触发, DMA数据传输   。电路原理框图见下:
1.png


DAC1产生的50HZ正弦波
2.png

相关代码
DAC.C
  1. #include "dac.h"
  2. DAC_HandleTypeDef hdac1;
  3. DMA_HandleTypeDef hdma_dac1_ch1;
  4. void MX_DAC1_Init(void)
  5. {
  6.   DAC_ChannelConfTypeDef sConfig = {0};
  7.   hdac1.Instance = DAC1;
  8.   if (HAL_DAC_Init(&hdac1) != HAL_OK)
  9.   {
  10.     Error_Handler();
  11.   }
  12.   sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC;
  13.   sConfig.DAC_DMADoubleDataMode = DISABLE;
  14.   sConfig.DAC_SignedFormat = DISABLE;
  15.   sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
  16.   sConfig.DAC_Trigger = DAC_TRIGGER_T2_TRGO;
  17.   sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE;
  18.   sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
  19.   sConfig.DAC_ConnectOnChipPeripheral =  DAC_CHIPCONNECT_ENABLE;
  20.   sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
  21.   if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
  22.   {
  23.     Error_Handler();
  24.   }
  25. }
  26. void HAL_DAC_MspInit(DAC_HandleTypeDef* dacHandle)
  27. {
  28.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  29.   if(dacHandle->Instance==DAC1)
  30.   {
  31.     __HAL_RCC_DAC1_CLK_ENABLE();
  32.     __HAL_RCC_GPIOA_CLK_ENABLE();
  33.     GPIO_InitStruct.Pin = GPIO_PIN_4;
  34.     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  35.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  36.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  37.     hdma_dac1_ch1.Instance = DMA1_Channel4;
  38.     hdma_dac1_ch1.Init.Request = DMA_REQUEST_DAC1_CHANNEL1;
  39.     hdma_dac1_ch1.Init.Direction = DMA_MEMORY_TO_PERIPH;
  40.     hdma_dac1_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
  41.     hdma_dac1_ch1.Init.MemInc = DMA_MINC_ENABLE;
  42.     hdma_dac1_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
  43.     hdma_dac1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  44.     hdma_dac1_ch1.Init.Mode = DMA_CIRCULAR;
  45.     hdma_dac1_ch1.Init.Priority = DMA_PRIORITY_MEDIUM;
  46.     if (HAL_DMA_Init(&hdma_dac1_ch1) != HAL_OK)
  47.     {
  48.       Error_Handler();
  49.     }
  50.     __HAL_LINKDMA(dacHandle,DMA_Handle1,hdma_dac1_ch1);
  51.   }
  52. }
  53. void HAL_DAC_MspDeInit(DAC_HandleTypeDef* dacHandle)
  54. {
  55.   if(dacHandle->Instance==DAC1)
  56.   {
  57.     __HAL_RCC_DAC1_CLK_DISABLE();
  58.     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4);
  59.     HAL_DMA_DeInit(dacHandle->DMA_Handle1);
  60.   }
  61. }
复制代码

ADC.C

  1. #include "adc.h"
  2. ADC_HandleTypeDef hadc1;
  3. ADC_HandleTypeDef hadc2;
  4. ADC_HandleTypeDef hadc3;
  5. DMA_HandleTypeDef hdma_adc1;
  6. DMA_HandleTypeDef hdma_adc2;
  7. DMA_HandleTypeDef hdma_adc3;
  8. void MX_ADC1_Init(void)
  9. {
  10.   ADC_MultiModeTypeDef multimode = {0};
  11.   ADC_ChannelConfTypeDef sConfig = {0};
  12.   hadc1.Instance = ADC1;
  13.   hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
  14.   hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  15.   hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  16.   hadc1.Init.GainCompensation = 0;
  17.   hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  18.   hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  19.   hadc1.Init.LowPowerAutoWait = DISABLE;
  20.   hadc1.Init.ContinuousConvMode = DISABLE;
  21.   hadc1.Init.NbrOfConversion = 1;
  22.   hadc1.Init.DiscontinuousConvMode = DISABLE;
  23.   hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T6_TRGO;
  24.   hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  25.   hadc1.Init.DMAContinuousRequests = ENABLE;
  26.   hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  27.   hadc1.Init.OversamplingMode = DISABLE;
  28.   if (HAL_ADC_Init(&hadc1) != HAL_OK)
  29.   {
  30.     Error_Handler();
  31.   }
  32.   multimode.Mode = ADC_MODE_INDEPENDENT;
  33.   if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
  34.   {
  35.     Error_Handler();
  36.   }
  37.   sConfig.Channel = ADC_CHANNEL_2;
  38.   sConfig.Rank = ADC_REGULAR_RANK_1;
  39.   sConfig.SamplingTime = ADC_SAMPLETIME_247CYCLES_5;
  40.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  41.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  42.   sConfig.Offset = 0;
  43.   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  44.   {
  45.     Error_Handler();
  46.   }
  47. }
  48. void MX_ADC2_Init(void)
  49. {
  50.   ADC_ChannelConfTypeDef sConfig = {0};
  51.   hadc2.Instance = ADC2;
  52.   hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
  53.   hadc2.Init.Resolution = ADC_RESOLUTION_12B;
  54.   hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  55.   hadc2.Init.GainCompensation = 0;
  56.   hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
  57.   hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  58.   hadc2.Init.LowPowerAutoWait = DISABLE;
  59.   hadc2.Init.ContinuousConvMode = DISABLE;
  60.   hadc2.Init.NbrOfConversion = 1;
  61.   hadc2.Init.DiscontinuousConvMode = DISABLE;
  62.   hadc2.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T6_TRGO;
  63.   hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  64.   hadc2.Init.DMAContinuousRequests = ENABLE;
  65.   hadc2.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  66.   hadc2.Init.OversamplingMode = DISABLE;
  67.   if (HAL_ADC_Init(&hadc2) != HAL_OK)
  68.   {
  69.     Error_Handler();
  70.   }
  71.   sConfig.Channel = ADC_CHANNEL_1;
  72.   sConfig.Rank = ADC_REGULAR_RANK_1;
  73.   sConfig.SamplingTime = ADC_SAMPLETIME_247CYCLES_5;
  74.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  75.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  76.   sConfig.Offset = 0;
  77.   if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
  78.   {
  79.     Error_Handler();
  80.   }
  81. }
  82. void MX_ADC3_Init(void)
  83. {
  84.   ADC_ChannelConfTypeDef sConfig = {0};
  85.   hadc3.Instance = ADC3;
  86.   hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
  87.   hadc3.Init.Resolution = ADC_RESOLUTION_12B;
  88.   hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  89.   hadc3.Init.GainCompensation = 0;
  90.   hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
  91.   hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV;
  92.   hadc3.Init.LowPowerAutoWait = DISABLE;
  93.   hadc3.Init.ContinuousConvMode = ENABLE;
  94.   hadc3.Init.NbrOfConversion = 1;
  95.   hadc3.Init.DiscontinuousConvMode = DISABLE;
  96.   hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  97.   hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  98.   hadc3.Init.DMAContinuousRequests = ENABLE;
  99.   hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  100.   hadc3.Init.OversamplingMode = DISABLE;
  101.   if (HAL_ADC_Init(&hadc3) != HAL_OK)
  102.   {
  103.     Error_Handler();
  104.   }
  105.   sConfig.Channel = ADC_CHANNEL_5;
  106.   sConfig.Rank = ADC_REGULAR_RANK_1;
  107.   sConfig.SamplingTime = ADC_SAMPLETIME_247CYCLES_5;
  108.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  109.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  110.   sConfig.Offset = 0;
  111.   if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  112.   {
  113.     Error_Handler();
  114.   }
  115. }

  116. static uint32_t HAL_RCC_ADC12_CLK_ENABLED=0;
  117. void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
  118. {
  119.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  120.   if(adcHandle->Instance==ADC1)
  121.   {
  122.     HAL_RCC_ADC12_CLK_ENABLED++;
  123.     if(HAL_RCC_ADC12_CLK_ENABLED==1){
  124.       __HAL_RCC_ADC12_CLK_ENABLE();
  125.     }
  126.     __HAL_RCC_GPIOA_CLK_ENABLE();
  127.     GPIO_InitStruct.Pin = GPIO_PIN_1;
  128.     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  129.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  130.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  131.     hdma_adc1.Instance = DMA1_Channel1;
  132.     hdma_adc1.Init.Request = DMA_REQUEST_ADC1;
  133.     hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
  134.     hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
  135.     hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
  136.     hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  137.     hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  138.     hdma_adc1.Init.Mode = DMA_CIRCULAR;
  139.     hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
  140.     if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
  141.     {
  142.       Error_Handler();
  143.     }
  144.     __HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc1);
  145.   }
  146.   else if(adcHandle->Instance==ADC2)
  147.   {
  148.     HAL_RCC_ADC12_CLK_ENABLED++;
  149.     if(HAL_RCC_ADC12_CLK_ENABLED==1){
  150.       __HAL_RCC_ADC12_CLK_ENABLE();
  151.     }
  152.     __HAL_RCC_GPIOA_CLK_ENABLE();
  153.     GPIO_InitStruct.Pin = GPIO_PIN_0;
  154.     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  155.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  156.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  157.     hdma_adc2.Instance = DMA1_Channel2;
  158.     hdma_adc2.Init.Request = DMA_REQUEST_ADC2;
  159.     hdma_adc2.Init.Direction = DMA_PERIPH_TO_MEMORY;
  160.     hdma_adc2.Init.PeriphInc = DMA_PINC_DISABLE;
  161.     hdma_adc2.Init.MemInc = DMA_MINC_ENABLE;
  162.     hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  163.     hdma_adc2.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  164.     hdma_adc2.Init.Mode = DMA_CIRCULAR;
  165.     hdma_adc2.Init.Priority = DMA_PRIORITY_LOW;
  166.     if (HAL_DMA_Init(&hdma_adc2) != HAL_OK)
  167.     {
  168.       Error_Handler();
  169.     }
  170.     __HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc2);
  171.   }
  172.   else if(adcHandle->Instance==ADC3)
  173.   {
  174.     __HAL_RCC_ADC345_CLK_ENABLE();
  175.     __HAL_RCC_GPIOB_CLK_ENABLE();
  176.     GPIO_InitStruct.Pin = GPIO_PIN_13;
  177.     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  178.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  179.     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  180.     hdma_adc3.Instance = DMA1_Channel3;
  181.     hdma_adc3.Init.Request = DMA_REQUEST_ADC3;
  182.     hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY;
  183.     hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE;
  184.     hdma_adc3.Init.MemInc = DMA_MINC_ENABLE;
  185.     hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  186.     hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  187.     hdma_adc3.Init.Mode = DMA_CIRCULAR;
  188.     hdma_adc3.Init.Priority = DMA_PRIORITY_LOW;
  189.     if (HAL_DMA_Init(&hdma_adc3) != HAL_OK)
  190.     {
  191.       Error_Handler();
  192.     }
  193.     __HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc3);
  194.   }
  195. }
  196. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
  197. {
  198.   if(adcHandle->Instance==ADC1)
  199.   {
  200.     HAL_RCC_ADC12_CLK_ENABLED--;
  201.     if(HAL_RCC_ADC12_CLK_ENABLED==0){
  202.       __HAL_RCC_ADC12_CLK_DISABLE();
  203.     }
  204.     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1);
  205.     HAL_DMA_DeInit(adcHandle->DMA_Handle);
  206.   }
  207.   else if(adcHandle->Instance==ADC2)
  208.   {
  209.     HAL_RCC_ADC12_CLK_ENABLED--;
  210.     if(HAL_RCC_ADC12_CLK_ENABLED==0){
  211.       __HAL_RCC_ADC12_CLK_DISABLE();
  212.     }
  213.     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
  214.     HAL_DMA_DeInit(adcHandle->DMA_Handle);
  215.   }
  216.   else if(adcHandle->Instance==ADC3)
  217.   {
  218.     __HAL_RCC_ADC345_CLK_DISABLE();
  219.     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
  220.     HAL_DMA_DeInit(adcHandle->DMA_Handle);
  221.   }
  222. }
复制代码

MAIN.C
  1. #include "main.h"
  2. #include "adc.h"
  3. #include "dac.h"
  4. #include "dma.h"
  5. #include "tim.h"
  6. #include "gpio.h"
  7. __IO uint32_t UserButtonStatus = 0;
  8. const uint16_t Sine12bit[60] = {0x07ff,0x08cb,0x0994,0x0a5a,0x0b18,0x0bce,0x0c79,0x0d18,0x0da8,0x0e29,0x0e98,0x0ef4,0x0f3e,0x0f72,0x0f92,0x0f9d,
  9. 0x0f92,0x0f72,0x0f3e,0x0ef4,0x0e98,0x0e29,0x0da8,0x0d18,0x0c79,0x0bce,0x0b18,0x0a5a,0x0994,0x08cb,0x07ff,0x0733,
  10. 0x066a,0x05a4,0x04e6,0x0430,0x0385,0x02e6,0x0256,0x01d5,0x0166,0x010a,0x00c0,0x008c,0x006c,0x0061,0x006c,0x008c,0x00c0,0x010a,0x0166,0x01d5,0x0256,0x02e6,0x0385,0x0430,0x04e6,0x05a4,0x066a,0x0733};
  11. uint16_t Result1[64];
  12. uint16_t Result2[64];
  13. uint16_t Result3[64];
  14. void SystemClock_Config(void);
  15. int main(void)
  16. {
  17.   HAL_Init();
  18.   SystemClock_Config();
  19.   MX_GPIO_Init();
  20.   MX_DMA_Init();
  21.   MX_ADC1_Init();
  22.   MX_TIM6_Init();
  23.   MX_ADC2_Init();
  24.   MX_ADC3_Init();
  25.   MX_DAC1_Init();
  26.   MX_TIM2_Init();
  27.         HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
  28.         HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
  29.         HAL_ADCEx_Calibration_Start(&hadc3, ADC_SINGLE_ENDED);
  30.         HAL_ADC_Start_DMA(&hadc1, (uint32_t *)&Result1,64);
  31.         HAL_ADC_Start_DMA(&hadc2, (uint32_t *)&Result2,64);
  32.         HAL_ADC_Start_DMA(&hadc3, (uint32_t *)&Result3,64);
  33.         HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1,
  34.                        (uint32_t*)Sine12bit, 60, DAC_ALIGN_12B_R);
  35.         HAL_TIM_Base_Start(&htim6);
  36.         HAL_TIM_Base_Start(&htim2);
  37.   while (1)
  38.   {
  39.   }
  40. }
  41. void SystemClock_Config(void)
  42. {
  43.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  44.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  45.   RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  46.   HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
  47.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  48.   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  49.   RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  50.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  51.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  52.   RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
  53.   RCC_OscInitStruct.PLL.PLLN = 85;
  54.   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  55.   RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  56.   RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  57.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  58.   {
  59.     Error_Handler();
  60.   }
  61.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  62.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  63.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  64.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  65.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  66.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  67.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  68.   {
  69.     Error_Handler();
  70.   }
  71.   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC12|RCC_PERIPHCLK_ADC345;
  72.   PeriphClkInit.Adc12ClockSelection = RCC_ADC12CLKSOURCE_SYSCLK;
  73.   PeriphClkInit.Adc345ClockSelection = RCC_ADC345CLKSOURCE_SYSCLK;
  74.   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  75.   {
  76.     Error_Handler();
  77.   }
  78. }
复制代码


    变量数组Result1[64]、Result2[64]、Result3[64]保存3个ADC通道的转换结果.   如果有多个 ADC内核同时工作,
各路ADC输入端同时采样一个正弦波信号时的数据应该基本相同的。

3.png

    从运行结果截图可以看出,各个数组的数据呈现明显的相位差,因此可以认为STM32G491的ADC应该是
使用同一个ADC内核,分时转换得到的。

ADC491.rar (751.97 KB, 下载次数: 6)
收藏 评论3 发布时间:2021-4-11 08:41

举报

3个回答
wyxy163@126.com 最优答案 回答时间:2021-4-11 11:15:52
肯定不是一个啊,手册说的很清楚"Each ADC consists of a 12-bit successive approximation analog-to-digital converter",这样判断一个内核本身就是逻辑错误,想要ADC采样结果一致,ADC这么用是肯定不行的
butterflyspring 回答时间:2021-4-15 11:44:08
从手册的描述上看,是三个模块,而且代码也是按ADC1,ADC2,ADC3分别初始化的哦。 另外从结果上看,第一组远远小于后面两组,所以建议楼主要适当检查一下硬件,从示意上看,至少输入阻抗没有看到。直接并联在采样时可能会有影响的,建议关注一下这方面
xmshao 回答时间:2021-5-10 11:25:42
可以肯定不是一个核。
你测试同一信号做验证是对的,但你不该将三个ADC输入并在一起。

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版