-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Describe the bug
I am trying to read 4 adc channels simultaneously with an STM32F411. The adc_read call only allows a single channel to be read with STM32 if not using DMA. This issue has been brought up a few times and the answer has generally been to be use DMA. There are a few issues related to it for example #19882 #34656 #32288 #39640
#52965 Is the pull request that provided STM32 ADC DMA support. None of the code examples I can find work for F4 chips. The test code in test/drivers/adc/adc_dma has code examples for H7, L4 and U5 chips, but not F4 chips.
The F4 chips use the st,stm32f4-adc and the st,stm32-dma-v1 node.
I tried running the test code with a stm32f4 board, but the MCU always resets when the dma_config function calls api->config(dev, channel, config); (Line 345 of include/zephyr/drivers/dma.h) The adc code calls dma_config from drivers/adc/adc_stm32.c adc_stm32_dma_start function.
DTS File:
#include <st/f4/stm32f411Xe.dtsi>
#include <st/f4/stm32f411r(c-e)tx-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>
.
.
.
&adc1 {
pinctrl-0 = <&adc1_in10_pc0 &adc1_in11_pc1
&adc1_in12_pc2 &adc1_in13_pc3 &adc1_in1_pa1>;
pinctrl-names = "default";
st,adc-clock-source = <SYNC>;
st,adc-prescaler = <2>;
status = "okay";
dmas = < &dma1 0 0 (STM32_DMA_PERIPH_TO_MEMORY |
STM32_DMA_MEM_INC | STM32_DMA_MEM_16BITS | STM32_DMA_PERIPH_16BITS) 0x3>;
dma-names = "dma";
#address-cells = <1>;
#size-cells = <0>;
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
channel@10 {
reg = <10>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
channel@11 {
reg = <11>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
channel@12 {
reg = <12>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
channel@13 {
reg = <13>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
};
test_dma: &dma1 {
status = "okay";
};
And I have the following in my config file:
CONFIG_ADC=y
CONFIG_DMA=y
CONFIG_ADC_STM32_DMA=y
CONFIG_ADC_ASYNC=y
Environment (please complete the following information):
- OS: Windows
- Zephyr 3.4.99