-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADC Voltage Reference issue with STM32U5 MCU #50895
Comments
@vibhor-meshram There were somesignificant changes on ADC during last release. Did you check status on V3.2 ? |
@erwango I tried to compile adc example using zephyr 3.2.0 version for nucleo_u575zi_q board. I set the reference to "ADC_REF_VDD_1_2". On compilation I got following error:- I fixed this error by making changes to gpio_stm32.c code. After successful compilation, the serial terminal output was as follows:-
I tried the above using reference as "ADC_REF_EXTERNAL0" as well and got the same results. |
With the nucleo_u575zi_q, the samples/drivers/adc gives:
|
Please run "west update". |
The error "Could not setup channel #0 (-22)" comes from the adc_stm32.c driver that only accepts the ADC_REF_INTERNAL as reference. In that case, the channel must define its vref :
|
@FRASTM Thanks for your resolution. Upon trying the the above solution my observation are as follows:-
|
Yes, the stm32 adc driver is limited to the ADC_REF_INTERNAL mainly, I guess, due to the hw design where the input pin VREF+ is VDDA = 3.3V |
I removed solder points that connects VDDA to Vref+ and now I am able to use external vref IC to provide reference voltage to my board. This worked without making any changes in the code ( Keeping the reference as ADC_REF_INTERNAL ). I am not sure about the enum provided for voltage reference. Is it only used for calculation purpose (convert raw data to mv) or it does some register configuration to use internal reference? |
The ADC_REF_INTERNAL is for calculation (giving the voltage for the Full range of ADC) |
Is there any way I could configure internal VREFBUF register to use as reference for ADC? |
There is an internal channel (0) in the ADC1 to measure the V Ref. |
Thanks @FRASTM for your help. I am closing the issue now. |
Any news on this? The driver still does not support using VDD as reference… |
Bug Description:-
I am using nucleo_u575zi_q board and wanted to implement ADC on it. my overlay file looks as follows:-
/ {
zephyr,user {
/* adjust channel number according to pinmux in board.dts */
io-channels = <&adc1 1>;
};
};
&adc1 {
#address-cells = <1>;
#size-cells = <0>;
};
I am trying to test the ADC code with different ADC reference voltages (like VDD, VDD/2, External etc), when I change the reference voltage, it doesn't have any effect on output ADC value. Also while debugging, I found that in adc_stm32.c file the following piece of code that allows only ADC_INTERNAL reference to set.
if (channel_cfg->reference != ADC_REF_INTERNAL) {
LOG_ERR("Invalid channel reference");
return -EINVAL;
}
Expected Behaviour:-
The ADC raw values should saturate when input voltage provided to ADC channel is equal to Vref set in the overlay file. For example if Vref is set to VDD/2, the ADC values should saturate if 1.65 volts is provided to ADC input channel.
Platform:-
Windows 10
Zephyr Version 3.1.0
The text was updated successfully, but these errors were encountered: