stm32 - 在双常规同步模式 STM32 中使用两个 DMA ADC channel

标签 stm32 dma adc

我想实现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/

相关文章:

assembly - STM32f103c8 gpio限速

c - 为什么 STM32 gcc 链接器脚本会自动丢弃这些标准库 : libc. a、libm.a、libgcc.a 中的所有输入节?

arm - 未配置STM32 WWDG中断触发

linux - Freescale (NXP) S32V234板,没有提供ADC驱动。

linux - 如何将 MCP23017 与 MCP3008 一起用于 Raspberry Pi 的 I2C 电压传感器?

c - 显示 %d 或 %u 时 snprintf 崩溃

linux - 为什么在没有 DMA 的情况下用套接字拼接不能提高性能?

linux - PCIe - DMA : Consistent vs. 流内存

stm32 - 指定超时后有意接收完成的 UART DMA 中断

emulation - GBZ80 - ADC 指令失败测试