Hello,
I am doing tests with the ADC of the STM32G071 and it is not possible to change the
resolution is always 12 bits.
.cfgr1 = ADC_CFGR1_RES_10BIT |
ADC_CFGR1_EXTEN_RISING |
ADC_CFGR1_EXTSEL_SRC(5),
Daniel
STM32G071 ADC resolution is always 12 bits Topic is solved
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: STM32G071 ADC resolution is always 12 bits
Hi,
The driver does not enforce 12 bits, is the value of the CFGR1 register what you expect after starting the conversion? perhaps that setting is not reaching the ADC for some reason.
Giovanni
The driver does not enforce 12 bits, is the value of the CFGR1 register what you expect after starting the conversion? perhaps that setting is not reaching the ADC for some reason.
Giovanni
Re: STM32G071 ADC resolution is always 12 bits
yes, the setting does not reach the ADC, regardless of the setting, bits 3 and 4 of CFGR1 remain at 0.
Daniel
Daniel
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: STM32G071 ADC resolution is always 12 bits
Hi,
Is that structure actually passed to adcStartConversion() ? please try to step into adc_lld_start_conversion() until the register is actually written (line 311), please check the value there.
Giovanni
Is that structure actually passed to adcStartConversion() ? please try to step into adc_lld_start_conversion() until the register is actually written (line 311), please check the value there.
Giovanni
Re: STM32G071 ADC resolution is always 12 bits
const ADCConversionGroup adcgrpcfg1 =
{
.circular = true,
.num_channels = ADC_GRP1_NUM_CHANNELS,
.end_cb = adcCallback, // NULL,
.error_cb = adcErrorCallback,
.cfgr1 = ADC_CFGR1_RES_12BIT |
ADC_CFGR1_EXTEN_RISING |
ADC_CFGR1_EXTSEL_SRC(5),
.cfgr2 = 0xCD,
....
}
adcStartConversion(&ADCD1, &adcgrpcfg1, samples1, ADC_GRP1_BUF_DEPTH);
CFGR1 0x00000543
CFGR2 0x000000CD
Daniel
{
.circular = true,
.num_channels = ADC_GRP1_NUM_CHANNELS,
.end_cb = adcCallback, // NULL,
.error_cb = adcErrorCallback,
.cfgr1 = ADC_CFGR1_RES_12BIT |
ADC_CFGR1_EXTEN_RISING |
ADC_CFGR1_EXTSEL_SRC(5),
.cfgr2 = 0xCD,
....
}
adcStartConversion(&ADCD1, &adcgrpcfg1, samples1, ADC_GRP1_BUF_DEPTH);
CFGR1 0x00000543
CFGR2 0x000000CD
Daniel
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: STM32G071 ADC resolution is always 12 bits
I am trying to understand if the driver writes the correct value and it is not "taken" by the CFGR1 register. What is the value of the "cfgr1" variable just before it is written in the register?
There are 2 cases:
1) The variable has the correct value and it is not latched into the register for some HW reason, then OK, we need to understand why.
2) The variable itself has a wrong value, this could be a SW bug in the driver somewhere (but I don't see anything in the code right now).
Debugging should be easier compiling with -O0 or optimizations could fool the debugger.
Giovanni
Code: Select all
/* ADC configuration and start.*/
adcp->adc->CFGR1 = cfgr1;
There are 2 cases:
1) The variable has the correct value and it is not latched into the register for some HW reason, then OK, we need to understand why.
2) The variable itself has a wrong value, this could be a SW bug in the driver somewhere (but I don't see anything in the code right now).
Debugging should be easier compiling with -O0 or optimizations could fool the debugger.
Giovanni
Re: STM32G071 ADC resolution is always 12 bits
Hi,
The cfgr1 variable has an incorrect value.
I defined a variable:
uint32_t CFGR1x;
/* ADC configuration and start.*/
adcp->adc->CFGR1 = cfgr1;
CFGR1x = cfgr1;
Then the value of CFGR1x is 0x00000543 (it should be 0x0000054B)
Daniel
The cfgr1 variable has an incorrect value.
I defined a variable:
uint32_t CFGR1x;
/* ADC configuration and start.*/
adcp->adc->CFGR1 = cfgr1;
CFGR1x = cfgr1;
Then the value of CFGR1x is 0x00000543 (it should be 0x0000054B)
Daniel
Re: STM32G071 ADC resolution is always 12 bits
Hi,
I did this test, something is writing in the structure.
uint32_t CFGR1x, CFGR1y, CFGR1z;
/* ADC configuration and start.*/
CFGR1x = ADC_CFGR1_RES_10BIT | ADC_CFGR1_EXTEN_RISING | ADC_CFGR1_EXTSEL_SRC(5) | ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG ;
adcp->adc->CFGR1 = CFGR1x; // cfgr1;
CFGR1y = adcp->adc->CFGR1;
CFGR1z = CFGR1x;
CFGR1x 0x0000054B
CFGR1y 0x00000543
CFGR1z 0x0000054B
Daniel
I did this test, something is writing in the structure.
uint32_t CFGR1x, CFGR1y, CFGR1z;
/* ADC configuration and start.*/
CFGR1x = ADC_CFGR1_RES_10BIT | ADC_CFGR1_EXTEN_RISING | ADC_CFGR1_EXTSEL_SRC(5) | ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG ;
adcp->adc->CFGR1 = CFGR1x; // cfgr1;
CFGR1y = adcp->adc->CFGR1;
CFGR1z = CFGR1x;
CFGR1x 0x0000054B
CFGR1y 0x00000543
CFGR1z 0x0000054B
Daniel
Re: STM32G071 ADC resolution is always 12 bits
This appears to be an errata. See ES0418 2.6.2, "Writing ADC_CFGR1 register while ADEN bit is set resets RES[1:0] bitfield".
Who is online
Users browsing this forum: No registered users and 18 guests