cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find documentation on ADC_IRQHandler()?

m12lrpv
Associate III

I'm using both ADC's in continuous / interrupt mode on some micro's in the STM32F103 family and it's working properly and fills my needs nicely.

The core components which are commonly presented in the online tutorials are...

Calibration:

HAL_ADCEx_Calibration_Start(&hadc1);
	HAL_ADCEx_Calibration_Start(&hadc2);

Starting the ADC's in continuous interrupt mode

HAL_ADC_Start_IT(&hadc1);
	HAL_ADC_Start_IT(&hadc2);

The Callback routine

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	if( hadc->Instance == ADC1)
	{
                ADC1_Reading = HAL_ADC_GetValue(&hadc1);
	}
	else if( hadc->Instance == ADC2)
	{
		ADC2_Thermistor =  HAL_ADC_GetValue(&hadc2);
	}
}

But the ADCs cannot operate in continuous interrupt mode without one critical component that is basically undocumented and almost none of the tutorials mention it.

ADC_IRQHandler()

I noted one post in this board that mentioned it and based on that I added ...

void ADC_IRQHandler()
{
    HAL_ADC_IRQHandler(&hadc1);
    HAL_ADC_IRQHandler(&hadc2);
}

After adding that it started working but I'm unable to find any documentation on it nor how to use it properly.

I'm hoping someone here can direct me to documentation regarding it. The RM0008 Reference manual for the STM32F1x family has no mention of it.

Edit (after waclawek's response): And neither does the "HAL and lower layer drivers" manual.

1 ACCEPTED SOLUTION

Accepted Solutions

The RM0008 does have an interrupt/exception table. The vector naming for a given chip (value, medium, xl or whatever) can be found in the startup.s file and this controls the linkage.

In addition to the DM and RM

https://www.st.com/resource/en/programming_manual/cd00228163-stm32f10xxx-20xxx-21xxx-l1xxxx-cortex-m3-programming-manual-stmicroelectronics.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

The RM documents the hardware, not software.

The ADC chapter in RM documents, under which circumstances is the interrupt invoked (ADC interrupts subchapter and description of ADC_CR1 (the xxxIE bits) and ADC_SR registers), and the interrupt chapter lists the interrupt vectors' position.

The name for interrupt service routine (ISR), i.e. ADC_IRQHandler() is given the by software (usually it's defined in the startup file, usually supplied by the toolchain you are using), and you can use anything for it if you want, as long as you insert it into the proper position in the interrupt vector table - except that there's no reason to do this.

The rest of it is entirely matter of Cube/HAL "library", so refer to the documentation of that.

JW

The RM0008 does have an interrupt/exception table. The vector naming for a given chip (value, medium, xl or whatever) can be found in the startup.s file and this controls the linkage.

In addition to the DM and RM

https://www.st.com/resource/en/programming_manual/cd00228163-stm32f10xxx-20xxx-21xxx-l1xxxx-cortex-m3-programming-manual-stmicroelectronics.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks.

So looking at RM0008 The interrupt acronym in my instance is actually ADC1_2

Then looking at

C:\Users\Administrator\STM32Cube\Repository\STM32Cube_FW_F1_V1.8.3\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\arm\startup_stm32f103xb.s

               DCD    DMA1_Channel7_IRQHandler  ; DMA1 Channel 7

               DCD    ADC1_2_IRQHandler         ; ADC1_2

               DCD    USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX

It appears that ADC1_2_IRQHandler is the defined function in the CubeMX templates

Going deeper still in my CubeIDE project it is defined as

void ADC1_2_IRQHandler(void)
{
  /* USER CODE BEGIN ADC1_2_IRQn 0 */
 
  /* USER CODE END ADC1_2_IRQn 0 */
  HAL_ADC_IRQHandler(&hadc1);
  HAL_ADC_IRQHandler(&hadc2);
  /* USER CODE BEGIN ADC1_2_IRQn 1 */
 
  /* USER CODE END ADC1_2_IRQn 1 */
}

Which leaves egg on my face because my addition of ADC_IRQHandler() actually did nothing it seems... I've just removed it and everything still works. 😳