cancel
Showing results for 
Search instead for 
Did you mean: 

ADC conversion with multiple channels (channel scanning) with interrupt

marco2
Associate III

I use STM32CubeIDE.

l have one external input (ADC_IN8), the internal temperature as a second channel (ADC_IN17) and Vdd voltage as the third channel.

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;

}

}

}

But something is wrong or not correctly set.

Anyone have any suggestion?

Thanks in advance

Stevasway

0 REPLIES 0