I am doing streaming processing on an audio signal, and I prefer to have a nice low-jitter sampling with very little software intervention. Previously I (with some help here) learned how to set up the ADC to trigger from TRG0 of the STM32's TIMx devices. That way I just get an interrupt when the ADC buffer is half-full and all the rest of the ADC operation is transparent to me after I start the device.
So my regular ADC config would be something like
Code: Select all
static const ADCConversionGroup adcgrpconf1 = {
.circular = TRUE,
.num_channels = ADC1_NUM_CHANNELS,
.end_cb = newAdcBufferCb,
.error_cb = NULL,
.u = { .adc = {
.cr1 = 0,
.cr2 = ADC_CR2_EXTSEL_2 | ADC_CR2_EXTTRIG, // Use TIM3_TRGO as source
.ltr = 0,
.htr = 0,
.smpr = { 0,
ADC_SMPR2_SMP_AN0(ADC_SAMPLE_1P5), },
.sqr = { ADC_SQR1_NUM_CH(ADC1_NUM_CHANNELS),
0,
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN0), },
},},
};
I would like to achieve something similar with the SDADC, but it seems that the TIMx TRG output isn't an option for a trigger source, only individual timer channels like TIM3 CH1. Is there a way to set up the GPT driver using the standard APIs to specifically set a TIMx CHy directly? I'm a bit confused about all the terminology and hoping someone has done something similar and can help.
So far my SDADC config is
Code: Select all
static const ADCConfig sdadc_config1 = {
.cr1 = 0,
.confxr = {
SDADC_CONFR_GAIN_1X | SDADC_CONFR_SE_ZERO_VOLT | SDADC_CONFR_COMMON_VSSSD,
0,
0,
},
};
static const ADCConversionGroup sdadcgrpcfg1 = {
.circular = TRUE,
.num_channels = ADC1_NUM_CHANNELS,
.end_cb = newAdcBufferCb,
.error_cb = 0x0,
.u = { .sdadc = {
.cr2 = SDADC_CR2_JEXTSEL_0 | SDADC_CR2_JEXTSEL_1 | SDADC_CR2_JEXTEN_1,
.jchgr = SDADC_JCHGR_CH(0),
.confchr = {
SDADC_CONFCHR1_CH0(0),
0,
},
},},
};
and my GPT config:
Code: Select all
static const GPTConfig gpt3cfg = {
.frequency = 80000,
.callback = 0x0,
.cr2 = 0,
.dier = 0
};
But when I start after I start the timer, the ADC callback is never called. Any help is greatly appreciated.