使用 STM32CubeIDE,
一个外部输入 (ADC_IN8),
内部温度作为第二个通道 (ADC_IN17),
Vdd 电压作为第三个通道。
程序读取不到数据,请问那里有错误??
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) { if (hadc->Instance == ADC1) { if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOC)) { ADC_raw[idx] = HAL_ADC_GetValue(&hadc1); idx++; } if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOS)) { idx=0; Vdd = (*VREFINT_CAL_ADDR)/ADC_raw[2]; temperature = (((int32_t)ADC_raw[1] * Vdd/3300)- (int32_t) *TEMPSENSOR_CAL1_ADDR ); temperature = temperature * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP); temperature = temperature / (int32_t)(*TEMPSENSOR_CAL2_ADDR - *TEMPSENSOR_CAL1_ADDR); temperature = temperature + TEMPSENSOR_CAL1_TEMP; Vin = Vdd*ADC_raw[0]/4095; } } }
|