cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Converter in STM32H745

JPiet.3
Associate III

I use the STM32H745 under the CubeIDE. I thought, when I configure my ADC to trigger the interrupt from a timer, the HAL_ADC_ConvCpltCallback() function will becalled automatically. The related ISR is called and I can read out the value. But the Callback-Function is not reached anymore.

As you see, I have the HAL_ADC_ErrorCallback() in my code, which a called everytime. But the Errorcode is zero. My assumption would be, with a errorcode Zero, the errorhandler will not be called. Is this behaviour wanted?

Third point is, if I set a breakpoint before the HAL_ADC_ErrorCallback(), e.g. line 7 in the TriggerCallback(), the debugger is jumping in the HAL_ADC_ErrorCallback(). What's happen here? The HAL_ADC_ConvHalfCpltCallback() is from my experiments to work with the DMA-Channels.

--- section from my sources ---
void TriggerCallback(TIM_HandleTypeDef *htim)
{
	adcConvComplete = 0;
//	printf("Trigger Callback\n");
 
}
 
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) {
	adcConvComplete = 1;
	printf("\033[7;1H ADC %d : ", adc_buffer[0]);
	printf("%d :", adc_buffer[1]);
}
 
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)
{
	static __IO int x=0, error;
	error = 1;
	error = (uint16_t)HAL_ADC_GetError(&hadc3);
//	if ( 0 != error)
		MYDEBUG("DMA Callback: %d %d\n", error, x++);
}
  
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
	adcConvComplete = 1;
	uint32_t result;
	result = HAL_ADC_GetValue(&hadc3);
	printf("\033[8;1H ADC Cplt %d : ", (uint16_t) result);
}

---IRQ-Handler from *it.c---
void ADC3_IRQHandler(void)
{
 /* USER CODE BEGIN ADC3_IRQn 0 */
	NVIC_ClearPendingIRQ(ADC_IRQn);
	HAL_ADC_Stop_IT(&hadc3);
 /* USER CODE END ADC3_IRQn 0 */
 
 HAL_ADC_IRQHandler(&hadc3);
 
 /* USER CODE BEGIN ADC3_IRQn 1 */
//	ADC3Val = HAL_ADC_GetValue(&hadc3);
// printf("\033[9;1H ADC Cplt Int %d", (uint16_t) ADC3Val);
 /* USER CODE END ADC3_IRQn 1 */
}
 

4 REPLIES 4
MM..1
Chief III

You dont show start code and completely dont understand your idea. Complete IRQ is used for big buffers and multi conversions. Read examples from firmware repository folders

.

JPiet.3
Associate III

Hi,

I start my ADC from a timer (not part from the sequence above). My aim in my project is, to read out a sequence of 4 channels from ADC3 via DMA. This is not working right now and I was going back to read out just one channel with interrrupt. And while doing this, I saw, the handler is reached, but the callback function isn't. The strange behaviour with the breakpoints s a side effect.

Jan

MM..1
Chief III

For start use bigger sample times, If your plan is sample four channels one sample , why not with pool method.

And HAL callbacks is based on ok IT file, you kill it with

---IRQ-Handler from *it.c---
void ADC3_IRQHandler(void)
{
 /* USER CODE BEGIN ADC3_IRQn 0 */
	NVIC_ClearPendingIRQ(ADC_IRQn);
	HAL_ADC_Stop_IT(&hadc3);
 /* USER CODE END ADC3_IRQn 0 */
 
 HAL_ADC_IRQHandler(&hadc3);
 
 /* USER CODE BEGIN ADC3_IRQn 1 */
//	ADC3Val = HAL_ADC_GetValue(&hadc3);
// printf("\033[9;1H ADC Cplt Int %d", (uint16_t) ADC3Val);
 /* USER CODE END ADC3_IRQn 1 */
}

JPiet.3
Associate III

To let the IRQHandler untouched was new for me. This solves my problem with the callback function. Thanks.