我想实现stm32f303 discovery的ADC1、ADC2和两个DMA ADC channel 的双常规同步模式。
在 CubeMX 示例中:
Usage of two DMA channels (one for ADC master, one for ADC slave) is also possible: this is the recommended configuration in case of high ADC conversions rates and applications using other DMA channels intensively.
根据 AN4195
When using the DMA, there are two possible cases: • Use of two separate DMA channels for master and slave. Each ADC (in this case, the MDMA[1:0]) must be kept cleared. The first DMA channel is used to read the master ADC converted data from ADC_DR, and the DMA requests are generated at each EOC event of the master ADC. The second DMA channel is used to read the slave ADC converted data from ADC_DR, and the DMA requests are generated at each EOC event of the slave ADC.
对于 1 个 channel ,代码:
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
HAL_ADC_Start(&hadc2);
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*)buffer, 3);
但是我们如何运行 2 个 channel 呢?据我了解,HAL_ADCEx_MultiModeStart_DMA 用于 1 个 channel
独立模式之类的东西不起作用
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
HAL_ADC_Start(&hadc2);
HAL_ADC_Start_DMA(&hadc1,(uint32_t*)ADC1_data,sizeof(ADC1_data)/sizeof(ADC1_data[0]));
HAL_ADC_Start_DMA(&hadc2,(uint32_t*)ADC2_data,sizeof(ADC2_data)/sizeof(ADC2_data[0]));
最佳答案
我不是 100% 确定这是否也适用于 F3 系列,但我已经为 F103C8 编写了有关 ADC 双常规同步模式的教程: http://www.bepat.de/2020/11/27/stm32f103c8-adc-dual-regular-simultaneous-mode/ 也许您会发现它很有帮助。
长话短说:我猜你启动 ADC 的方式是错误的。 ADC2 需要在 ADC1 启动之前以正常模式启动
HAL_ADC_Start(&hadc2);
ADC1 随后启动:
HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC_Buffer, ADC_BufferSize);
关于stm32 - 在双常规同步模式 STM32 中使用两个 DMA ADC channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45153640/