Hi, I have an application with STM32G431RB, using both ADCs. How can I tell which one of the two ADCs called an interruption like this: void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc)
..
..
Hello, thanks a lot for your answers, I implement it in a different way with your recommendations and is now working fine:
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc)
{
// Voltage1 = HAL_ADCEx_InjectedGetValue(&hadc1, ADC_INJECTED_RANK_2); // L1 VOLTAGE
if (hadc->Instance == ADC1)
{
Line1[0] += ADC1->JDR1; // Gets L1 Current. ADC1 Channel 1. PA0 pin
Line1[1] += ADC1->JDR2; // Gets L1 Voltage. ADC1 Channel 9. PC3 pin
Line1[2] += ADC1->JDR3; // Gets IGBT Temperature. ADC1 Channel 7. PC1 pin
Line1[3] += ADC1->JDR4; // Gets BUS Voltage. ADC1 Channel 2. PA1 pin
samples1++;
if (samples1 >= L1_SAMP)
{
samples1 = 0;
CalcLine1AVG();
}
HAL_ADCEx_InjectedStop_IT(&hadc1);
}
else if (hadc->Instance == ADC2)
{
Line2[0] += ADC2->JDR1; // Gets L1 Voltage. ADC1 Channel 9. PC3 pin
HAL_ADCEx_InjectedStop_IT(&hadc2);
samples2++;
if (samples2 >= L2_SAMP)
{
samples2 = 0;
CalcLine2AVG();
}
}
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.