cancel
Showing results for 
Search instead for 
Did you mean: 

zephyr stm32u5g9j-dk2 adc not function

devin-hu
Associate II
Hello, I am using the Zephyr operating system with the STM32U5G9J-DK2 hardware. I intend to collect voltage data using the ADC, but so far, no progress has been made. Here are the steps I have taken:
  • I used the zephyr\samples\drivers\adc\adc_sequence example from Zephyr 4.2.0.
  • I created a new app.overlay file in the root Vmakelists.txt directory with the following content:
     
    / {
        aliases {
            adc0 = &adc1;
        };
    };
    
    &vbat1 {
        status = "okay";
        io-channels = < &adc1 5 >;
    };
     
  • I compiled using this command:west build -p always -b stm32u5g9j_dk2 --sysbuild .
  • Then I supplied 1V to the PA0 pin (silkscreen labeled PWM/D6), and the log is as follows:
  •  
     
[16:22:28.487] RX←◆*** Booting Zephyr OS build v4.2.0 ***ADC sequence reading [0]:
[16:22:29.493] RX←◆- adc@42028000, channel 5, 5 sequence samples:

2684 = 2162mV

1788 = 1440mV

1571 = 1265mV

1532 = 1234mV

1492 = 1202mV

adc@42028000, channel 12, 5 sequence samples:

2092 = 1685mV

1660 = 1337mV

1571 = 1265mV

1532 = 1234mV

1532 = 1234mV

  • Subsequently, I changed the supply voltage to 2V, and the log is as follows:[16:27:39.509] RX←◆- adc@42028000, channel 5, 5 sequence samples:

0 = 0mV

1068 = 860mV

1404 = 1131mV

1492 = 1202mV

1492 = 1202mV

adc@42028000, channel 12, 5 sequence samples:

636 = 512mV

1315 = 1059mV

1492 = 1202mV

1492 = 1202mV

1532 = 1234mV

No significant changes are observable. I also tried the example in samples\boards\st\power_mgmt\adc\src\main.c, but still cannot obtain correct results. Could you please advise on how to acquire accurate ADC values using Zephyr?
0 REPLIES 0