2019-11-07 03:36 AM
Hello,
in my project I connected 6 channels to ADC3; then i set up:
I want to use oversampling for both regular and injected conversions (the RM states that this is possible).
Setup of ADC 3 is the following:
static ADC_InitTypeDef initADC3 = //Monitoring ADC
{
ADC_CLOCK_ASYNC_DIV4, //ClockPrescaler
ADC_RESOLUTION_16B, //Resolution
ADC_SCAN_ENABLE, //Configure the sequencer of ADC groups regular and injected.
ADC_EOC_SEQ_CONV, //Specify which EOC (End Of Conversion)
DISABLE, //Low power Auto Delay
DISABLE, //Conversion is performed in single mode (one conversion)
5, //Number of ranks converted within the regular group sequencer.
DISABLE, //Complete-sequence/Discontinuous-sequence
1, //Specifies the number of discontinuous - Discarded here
ADC_SOFTWARE_START, //Event source used to trigger ADC group regular conversion start.
ADC_EXTERNALTRIGCONVEDGE_NONE,
ADC_CONVERSIONDATA_DMA_CIRCULAR,
ADC_OVR_DATA_OVERWRITTEN,//Select the behavior in case of overrun
ADC_LEFTBITSHIFT_NONE,
ENABLE, // oversampling feature is enabled
{ //Oversampling parameters
3, //Ratio
ADC_RIGHTBITSHIFT_2, // Right-shift 2 bit (/4) -> Sum of 4 val, then /4 -> Average
ADC_TRIGGEREDMODE_SINGLE_TRIGGER,
ADC_REGOVERSAMPLING_RESUMED_MODE
}
};
Setup of regular channels is the following:
static ADC_ChannelConfTypeDef ADC3_ChannelConf[] =
{
//Sens 12V_PWR
{ ADC_CHANNEL_7, ADC_REGULAR_RANK_1, ADC_SAMPLETIME_8CYCLES_5, ADC_SINGLE_ENDED, ADC_OFFSET_NONE, 0, DISABLE, DISABLE },
//Sens_3v3A
{ ADC_CHANNEL_8, ADC_REGULAR_RANK_2, ADC_SAMPLETIME_8CYCLES_5, ADC_SINGLE_ENDED, ADC_OFFSET_NONE, 0, DISABLE, DISABLE },
//Sens_15V
{ ADC_CHANNEL_10, ADC_REGULAR_RANK_3, ADC_SAMPLETIME_8CYCLES_5, ADC_SINGLE_ENDED, ADC_OFFSET_NONE, 0, DISABLE, DISABLE },
//Sens_n15V
{ ADC_CHANNEL_11, ADC_REGULAR_RANK_4, ADC_SAMPLETIME_8CYCLES_5, ADC_SINGLE_ENDED, ADC_OFFSET_NONE, 0, DISABLE, DISABLE },
//Sens 5Va
{ ADC_CHANNEL_12, ADC_REGULAR_RANK_5, ADC_SAMPLETIME_8CYCLES_5, ADC_SINGLE_ENDED, ADC_OFFSET_NONE, 0, DISABLE, DISABLE },
};
And of the injected channel:
static ADC_InjectionConfTypeDef ADC3_JChannelConf[] =
{
{
ADC_CHANNEL_2, // Specifies the channel to configure into ADC group injected.
ADC_INJECTED_RANK_1, // Specifies the rank in the ADC group injected sequencer.
ADC_SAMPLETIME_8CYCLES_5, // Sampling time value to be set for the selected channel.
ADC_SINGLE_ENDED, // Selection of single-ended or differential input.
ADC_OFFSET_NONE, // Selects the offset number.
0, // Offset to be subtracted from the raw converted data.
DISABLE, // Specifies whether the 1 bit Right-shift feature is used or not.
DISABLE, // Signed saturation feature not used ADC_LEFTBITSHIFT_NONE, // Configures the left shifting applied to the final result
1, // Number of ranks that will be converted within the ADC group injected sequencer.
DISABLE, // Complete-sequence/Discontinuous-sequence
DISABLE, // Disables injected automatic conversion after regular one
DISABLE, // Specifies whether the context queue feature is enabled.
ADC_INJECTED_SOFTWARE_START, // Trigger the conversion start of injected group.
ADC_EXTERNALTRIGINJECCONV_EDGE_NONE,
ENABLE, // oversampling feature is enabled
{ //Oversampling parameters
3, // Ratio
ADC_RIGHTBITSHIFT_2 // Right-shift 2 bit (/4) -> Sum of 4 val, then /4 -> Average
}
}
};
At this stage of debugging I never call the ADC_PerformInjectedConversion() function, so I am sure that only regular sequences are performed.
The problem is :
May it be just a configuration problem ?
Any suggestions ?
Thank you