Code: Select all
/* The start method is different depending if HW or SW triggered, the
start is performed using the method specified in the CR2 configuration.*/
if ((cr2 & ADC_CR2_SWSTART) != 0) {
/* Initializing CR2 while keeping ADC_CR2_SWSTART at zero.*/
adcp->adc->CR2 = (cr2 | ADC_CR2_CONT) & ~ADC_CR2_SWSTART;
/* Finally enabling ADC_CR2_SWSTART.*/
adcp->adc->CR2 = (cr2 | ADC_CR2_CONT);
}
else
adcp->adc->CR2 = cr2;
}
The "Finally enabling ADC_CR2_SWSTART." code should be:
Code: Select all
adcp->adc->CR2 = (cr2 | ADC_CR2_SWSTART);