cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Interrupt

Utkarash Patil
Associate III
Posted on November 10, 2017 at 07:28

I have used STM CubeMX and Keil u5 and i have interfaced a Potentiometer with Nucleo  STM32F103RB Devkit so i am getting  ADC Values using  these function,

  '

HAL_ADC_Start_DMA(&hadc1,ui32ReadADCBuffer,3);

    ui32Pot1 = ui32ReadADCBuffer[0];

   ui32Pot2 = ui32ReadADCBuffer[1];

   ui32Pot3 = 

ui32ReadADCBuffer[2];

  '

But Is there any way where i can read the ADC values only when the potentiometer(POT) is rotated means do we have any  callback fuction for it to interrupt the flow of code once the Potentiometer(POT)  values are changed

Like if intially the POT position is stable i will not read ADC values but when i rotate or change the POT value i should a callback or interrupt then i will perfor these instructions '

' ui32Pot1 = ui32ReadADCBuffer[0];  ui32Pot2 = ui32ReadADCBuffer[1]; 

ui32Pot3 = 

ui32ReadADCBuffer[2];

 

 

'

I got one function but i am not able to get the exact use or functionality of that function please check with this function and also if there is any other way i can achieve the above told interrupt please let help me.

2 REPLIES 2
Utkarash Patil
Associate III
Posted on November 10, 2017 at 07:29

I have used STM CubeMX and Keil u5 and i have interfaced a Potentiometer with Nucleo  STM32F103RB Devkit so i am getting  ADC Values using  these function,

'

 

HAL_ADC_Start_DMA(&hadc1,ui32ReadADCBuffer,3);

    ui32Pot1 = ui32ReadADCBuffer[0];

   ui32Pot2 = ui32ReadADCBuffer[1];

   ui32Pot3 = 

ui32ReadADCBuffer[2];

 

 

'

But Is there any way where i can read the ADC values only when the potentiometer(POT) is rotated means do we have any  callback fuction for it to interrupt the flow of code once the Potentiometer(POT)  values are changed

Like if intially the POT position is stable i will not read ADC values but when i rotate or change the POT value i should a callback or interrupt then i will perfor these instructions '

'

 ui32Pot1 = ui32ReadADCBuffer[0]; 

 ui32Pot2 = ui32ReadADCBuffer[1]; 

ui32Pot3 = 

ui32ReadADCBuffer[2];

 

 

'

I got one function but i am not able to get the exact use or functionality of that function ( 'HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc1)' )please check with this function and also if there is any other way i can achieve the above told interrupt please let help me.

Posted on November 10, 2017 at 08:51

But Is there any way where i can read the ADC values only when the potentiometer(POT) is rotated means do we have any  callback fuction for it to interrupt the flow of code once the Potentiometer(POT)  values are changed

No.

And actually, you don't want that.

The ADC value will always have some noise, two or three bits at average. How will you discern such value changes (noise) from potentiometer turns ?