cancel
Showing results for 
Search instead for 
Did you mean: 

EVSPIN32G4NH - opamp ADC (OPO1) doesn't work

Sheng123
Associate

Dear community 

I would like to clarify regarding current sensing configuration of EVSPIN32G4NH. Below are my method and verification step to setup the configuration of ADC and OPAMP. I setup 1 channel of ADC instead of 2 or 3 channels to avoid complexity.

1. I use 'standalone mode of OPAMP1 and GPIO settings per below image. Also, attached my ADC setup for single channel. To show huge jump of ADC values, I supply DAC (PA5) to ADC (PA2) and short it. However, from the output always 0 per below image. Also, below is my code to display ADC values.

PA1 - OPAMP1_VINP

PA2 - ADC1_IN3 & OPAMP1_VOUT

PA3 - OPAMP1_VINM

 

image-20250210-092031.png

image-20250210-092245.png

image-20250210-092128.png

However I can't read any value from the ADC

 

image-20250210-093131.png

and here is my code

 

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
    if (hadc->Instance == ADC2)  // Check if ADC1 triggered the callback
    {
        adc_ready_flag = 1;  // Set a flag to indicate data is ready
    }
}

  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

	    HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, value_dac);
	    value_dac++;
	    if(value_dac>4095) {
	      value_dac=0;
	    }
	    printf("ADC: %ld, DAC: %ld\r\n",value_adc,value_dac);

  }

 


So in order to clarify the problem, I try to use another ADC2 pin (PA4) and use exactly same setup as ADC1 (PA2). Same method is used, where i supply ADC2 with DAC (PA5) and short it. It can show correct digital values per below image that tally with DAC input.

image-20250210-093234.png

image-20250210-092935.png

And I can read the value right now, and here is my code

 

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
    if (hadc->Instance == ADC1)  // Check if ADC1 triggered the callback
    {
        adc_ready_flag = 1;  // Set a flag to indicate data is ready
    }
}

  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

	    HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, value_dac);
	    value_dac++;
	    if(value_dac>4095) {
	      value_dac=0;
	    }
	    printf("ADC1: %ld, DAC: %ld\r\n",value_adc1,value_dac);

  }

 

 

So it looks like the code and ADC settings should be correct, but we are still unable to get a value from OpAmp PA2(OPO1) value.
Could you assist us in troubleshooting this issue?

Thanks a lot!

0 REPLIES 0