cancel
Showing results for 
Search instead for 
Did you mean: 

ADC and DMA

jakob.brunhart
Associate III

Hi,

I'm using ADC1 in combination with DMA (One-Shot-Mode). The ADC is used read out a spectrometer (288 pixel). Starting the read function does the following procedure:

  1. HAL_ADC_Start_DMA( &hadc1, buffer, 288);
  2. Wait for callback: HAL_ADC_ConvCpltCallback();
  3. HAL_ADC_Stop_DMA( &hadc1 );

HAL_ADC_Stop_DMA( &hadc1 ) results in the error: HAL_DMA_ERROR_NO_XFER. The error is set in stm32h7xx_hal_dma.c (line 752).

  /* Check the DMA peripheral state */
  if(hdma->State != HAL_DMA_STATE_BUSY)
  {
    hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
 
    /* Process Unlocked */
    __HAL_UNLOCK(hdma);
 
    return HAL_ERROR;
  }
 

The callback HAL_ADC_ConvCpltCallback(); is called by the DMA (transfer complete interrput). And here the hdma->State is set to HAL_DMA_STATE_READY.

        /* Disable the transfer complete interrupt if the DMA mode is not CIRCULAR */
        else
        {
          if((((DMA_Stream_TypeDef   *)hdma->Instance)->CR & DMA_SxCR_CIRC) == RESET)
          {
            /* Disable the transfer complete interrupt */
            ((DMA_Stream_TypeDef   *)hdma->Instance)->CR  &= ~(DMA_IT_TC);
 
            /* Process Unlocked */
            __HAL_UNLOCK(hdma);
 
            /* Change the DMA state */
            hdma->State = HAL_DMA_STATE_READY;
          }
 
          if(hdma->XferCpltCallback != NULL)
          {
            /* Transfer complete callback */
            hdma->XferCpltCallback(hdma);
          }
        }

(line 1324 in file stm32h7xx_hal_dma.c)

In my opinion this results always in this error.

Any idea?

Regards

Jakob

0 REPLIES 0