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