fix ADC lockup while reading
This commit is contained in:
parent
70bf2c481f
commit
d42f20773b
|
@ -81,18 +81,20 @@ void adc_convert()
|
|||
|
||||
void adc_read()
|
||||
{
|
||||
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
|
||||
if (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)) {
|
||||
adc_val[adc_val_idx++] = ADC_GetConversionValue(ADC1);
|
||||
adc_val_idx &= 0x0f;
|
||||
if (!adc_val_idx) adc_calc_avg();
|
||||
|
||||
if (ADC1->CTLR1 & ADC_JAUTO) {
|
||||
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_JEOC));
|
||||
if (ADC_GetFlagStatus(ADC1, ADC_FLAG_JEOC)) {
|
||||
lsens_val = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_1);
|
||||
|
||||
// reset LSENS
|
||||
ADC_AutoInjectedConvCmd(ADC1, DISABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adc_use_lsens()
|
||||
|
|
Loading…
Reference in New Issue