Currently, the code is:
Code: Select all
#if STM32_ADC_USE_SDADC2
...
rccEnableSDADC1(FALSE);
...
#endif /* STM32_ADC_USE_SDADC2 */
#if STM32_ADC_USE_SDADC3
...
rccEnableSDADC1(FALSE);
...
#endif /* STM32_ADC_USE_SDADC3 */
The code enables the clocks to the incorrect SDADCs.
Also, in the same file, the function adc_lld_start_conversion does this:
Code: Select all
void adc_lld_start_conversion(ADCDriver *adcp) {
...
/* Leaving initialization mode.*/
adcp->sdadc->CR1 &= ~SDADC_CR1_INIT;
/* SDADC conversion start, the start is performed using the method
specified in the CR2 configuration, usually SDADC_CR2_JSWSTART.*/
adcp->sdadc->CR2 = cr2;
...
In my application, the trigger is not SDADC_CR2_JSWSTART, but an external event generated by a timer (chosen with bits SDADC_CR2_JEXTSEL and SDADC_CR2_JEXTEN). Those bits can only be written if INIT = 1, so my "quick fix" was to duplicate the assignment to CR2 (note that SDADC_CR2_JSWSTART can only be written when INIT = 0). I don't know the best way to fix this issue... but here is my code:
Code: Select all
void adc_lld_start_conversion(ADCDriver *adcp) {
...
adcp->sdadc->CR2 = cr2;
/* Leaving initialization mode.*/
adcp->sdadc->CR1 &= ~SDADC_CR1_INIT;
/* SDADC conversion start, the start is performed using the method
specified in the CR2 configuration, usually SDADC_CR2_JSWSTART.*/
adcp->sdadc->CR2 = cr2;
...
Thanks!
Diego.