cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_ADC_ConvtCpltCallback not getting triggered

JWieb
Associate III

Working with the STM32WB5MM.

My intent is to trigger a one shot ADC/DMA combo that will read a bunch of pins with heavy oversampling, then trigger a callback for the processor to deal with later.

Core Clock is 32Mhz, ADC clock is 1Mhz

I've got the ADC DMA working properly but the callback is not.. Here is my code:

#define ADC_DMA_CHANNELS   2
volatile uint16_t rawADC[ADC_DMA_CHANNELS];		//stores values from the ADC DMA
 
void ADC_Start(void){
	APP_DBG_MSG("Start ADC \n");
	//Start and Calibrate ADC
	HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
	//Start ADC into DMA
	HAL_ADC_Start_DMA(&hadc1, (uint32_t*)rawADC, ADC_DMA_CHANNELS);
 
	HAL_Delay(10); //Block code to verify results
	APP_DBG_MSG("While %d %d\n", rawADC[0], rawADC[1]); //This prints proper results
	HAL_ADC_Stop_DMA(&hadc1);
	return;
}
 
void HAL_ADC_ConvtCpltCallback  (ADC_HandleTypeDef *hadc) {
	APP_DBG_MSG("HAL_ADC_ConvtCpltCallback %d %d\n", rawADC[0], rawADC[1]); //Never gets triggered
}
 
static void MX_DMA_Init(void)
{
 
  /* DMA controller clock enable */
  __HAL_RCC_DMAMUX1_CLK_ENABLE();
  __HAL_RCC_DMA2_CLK_ENABLE();
 
  /* DMA interrupt init */
  /* DMA2_Channel1_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Channel1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Channel1_IRQn);
}
 
static void MX_ADC1_Init(void)
{
 
 
  ADC_ChannelConfTypeDef sConfig = {0};
  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV32;
  hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc1.Init.LowPowerAutoWait = DISABLE;
  hadc1.Init.ContinuousConvMode = DISABLE;
  hadc1.Init.NbrOfConversion = 2;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  hadc1.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Regular Channel
  */
  sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SamplingTime = ADC_SAMPLETIME_24CYCLES_5;
  sConfig.SingleDiff = ADC_SINGLE_ENDED;
  sConfig.OffsetNumber = ADC_OFFSET_NONE;
  sConfig.Offset = 0;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Regular Channel
  */
  sConfig.Channel = ADC_CHANNEL_VBAT;
  sConfig.Rank = ADC_REGULAR_RANK_2;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN ADC1_Init 2 */
 
  /* USER CODE END ADC1_Init 2 */
}

1 REPLY 1
JWieb
Associate III

SORRY! Spelling mistake killed me here...

HAL_ADC_ConvCpltCallback