cancel
Showing results for 
Search instead for 
Did you mean: 

STM32h735g ADC3 Support in Zephyr

anthonyog
Associate II

I am trying to use pins on ADC3 of an STM32h735g in Zephyr, but I am getting a "Could not read (-22)" error, despite not having issues with ADC1. Is ADC3 supported? If so, can you help me with how to configure it?

This is based on the Zephyr samples/drivers/adc/adc_dt and I am using the stm32h735g Discovery Kit to test this.

I modified boards/stm32h735g_disco.overlay to

/* Copyright (c) 2021 STMicroelectronics
   SPDX-License-Identifier: Apache-2.0 */

 / {
	zephyr,user {
		/* Adding adc3 1 to the existing definition of io-channels */
		io-channels = <&adc1 0>, <&adc3 1>;
	};
};

&adc1 {
	#address-cells = <1>;
	#size-cells = <0>;

	channel@0 {
		reg = <0>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <16>;
	};
};

/* The following I defined for adc3 */
&adc3 {
	#address-cells = <1>;
	#size-cells = <0>;
        /* Compiler requiess definition for the following on adc3*/
	pinctrl-0 = <&adc3_inp0_pc2_c>;
	pinctrl-names = "default";
	st,adc-clock-source = <SYNC>;
	st,adc-prescaler = <4>;
	status = "okay";

	channel@1 {
		reg = <1>;
		zephyr,gain = "ADC_GAIN_1";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <16>;
		status = "okay";
	};
};

However the output is

ADC reading[0]: 
- adc@40022000, channel 0: 2278 = 114 mV
- adc@58026000, channel 1: Could not read (-22)

 

10 REPLIES 10
anthonyog
Associate II

Using a revision Z chip and changing the resolution to "<8>", I am able to read voltage on adc3 channel 0, but I get 0 for any other channel. The channels of interest for me are 1, 2, 0xF, and 0xE. Should those pins be available for the ADC in rev Z?

I am using Zephyr 3.7.0