cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55 ADC Single scan (A/D9, A/D9, A/D10), using DMA AND LPTimer --- not seeing any values?

SWenn.1
Senior III

Good afternoon....

Trying to trigger scan mode (2 channels but 3 conversions ---- A/D 9, A/D 9, A/D 10) via software trigger that is called in the LPTIMER (I do not have access to other timers bcz they are tied up in other code that is why I am not using a trigger output) callback function. Can someone see something I am missing as the adcValue array is always empty ?

ADC CubeMx settings:

0693W00000JM8cIQAT.png 

DMA CubeMx settings:

0693W00000JM8chQAD.png 

Main IRQ code: (In debugger I can see the timer running and I am getting to the Start DMA)

void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
	if (hlptim == &hlptim1) //debounce timer
	{
		HAL_LPTIM_OnePulse_Stop_IT(&hlptim1);
 
		if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_1) == GPIO_PIN_RESET)
		{
			EXTI->PR1 |= EXTI_PR1_PIF1; //clear any that came AFTER debounce
			EXTI->IMR1 |= EXTI_IMR1_IM1; //enable / unmask
 
			ISR.B_LockOut = T;
		}
	}
	else
	{
		HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, 0); //LED on
//		HAL_ADC_Start_IT(&hadc1);
 	    hadc1.Instance->IER |= ADC_EOC_SEQ_CONV;
		HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adcValue, AD_NUMBERSAMPLES);
	}
}
 
/*
 * A/D conversion complete callback
 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
	if (hadc == &hadc1)
	{
//		adcValue[cnt] = HAL_ADC_GetValue(&hadc1);
//		cnt++;
//		if ((hadc1.Instance->ISR) & 8UL)
//		{
//			HAL_ADC_Stop_IT(&hadc1);
			HAL_ADC_Stop_DMA(&hadc1);
			hadc1.Instance->IER &= ~ADC_EOC_SEQ_CONV;
			hadc1.Instance->ISR |= ADC_EOC_SEQ_CONV;
//			cnt = 0;
			ISR.A_Conversion = T;
//		}
	}
}

Thank you.....

1 REPLY 1
Amel NASRI
ST Employee

Hi @SWenn.1​ ,

I see a follow-up of your question here.

If it is still open, please make sure that HAL_DMA_Init() is called before HAL_ADC_Init()?

It is probable that you face this regression issue if you aren't using latest STM32CubeMX version (6.4).

Some more details in this post.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.