cancel
Showing results for 
Search instead for 
Did you mean: 

multichannel ADC with DMA reads only 0

JWeij.1
Associate

For my project, i have to read the PA6 and PB0 pins at the same time on my STML082KZT6. These are the ADC_Inch 6 and 8. I have made a code example on STM32CubeMX for the allocations, however the only readings i get are zero.

I have allocated uint32_t VR[2] for data storage,

I initialize the DMA with: HAL_ADC_Start_DMA(&hadc, VR, 2);

In my loop i print the VR[0] and VR[1] bit but those are always 0 even thought the input clearly is not.

Below are my ADC and DMA setups

static void MX_ADC_Init(void)
 
{
 
 
 
  /* USER CODE BEGIN ADC_Init 0 */
 
 
 
  /* USER CODE END ADC_Init 0 */
 
 
 
  ADC_ChannelConfTypeDef sConfig = {0};
 
 
 
  /* USER CODE BEGIN ADC_Init 1 */
 
 
 
  /* USER CODE END ADC_Init 1 */
 
  /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 
 
  */
 
  hadc.Instance = ADC1;
 
  hadc.Init.OversamplingMode = DISABLE;
 
  hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV1;
 
  hadc.Init.Resolution = ADC_RESOLUTION_12B;
 
  hadc.Init.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
 
  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
 
  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 
  hadc.Init.ContinuousConvMode = ENABLE;
 
  hadc.Init.DiscontinuousConvMode = DISABLE;
 
  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 
  hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 
  hadc.Init.DMAContinuousRequests = DISABLE;
 
  hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 
  hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 
  hadc.Init.LowPowerAutoWait = DISABLE;
 
  hadc.Init.LowPowerFrequencyMode = DISABLE;
 
  hadc.Init.LowPowerAutoPowerOff = DISABLE;
 
  if (HAL_ADC_Init(&hadc) != HAL_OK)
 
  {
 
    Error_Handler();
 
  }
 
  /** Configure for the selected ADC regular channel to be converted. 
 
  */
 
  sConfig.Channel = ADC_CHANNEL_6;
 
  sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
 
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
 
  {
 
    Error_Handler();
 
  }
 
  /** Configure for the selected ADC regular channel to be converted. 
 
  */
 
  sConfig.Channel = ADC_CHANNEL_8;
 
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
 
  {
 
    Error_Handler();
 
  }

static void MX_DMA_Init(void) 
 
{
 
 
 
  /* DMA controller clock enable */
 
  __HAL_RCC_DMA1_CLK_ENABLE();
 
 
 
  /* DMA interrupt init */
 
  /* DMA1_Channel1_IRQn interrupt configuration */
 
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
 
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
 
 
 
}

0 REPLIES 0