Example for ADC in multimode with dual DMA?
Hi,
I want to use the simulataneous ADC reading with 2 DMA channels, in order to avoid overrun errors (which I'm having).
I'm using the HAL and I'm having a hard time understanding when is the DMA buffer of the slave channel assigned. When multimode is used, all the manuals and explanations I've seen recommed this structure:
if (HAL_ADC_Start(&hadc2) != HAL_OK) Error_Handler();
if (HAL_ADCEx_MultiModeStart_DMA(&hadc1, getDMAADCBufferPointer(), ADC_BUFFER_LENGTH) != HAL_OK) Error_Handler();Where the slave is started first, but then you are not able to tell the system to use the slave DMA buffer. If I use the same ADC for both, the sampling, transmission to DMA and all happen correctly. But using different DMA channels, I can see the DR registers of the ADC being updated, but the DMA interrupt (HAL_ADC_ConvCpltCallback) does not happen.
The interrupt mapping is:
/**
* @brief This function handles DMA1 channel1 global interrupt.
*/
void DMA1_Channel1_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
/* USER CODE END DMA1_Channel1_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc1);
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
/* USER CODE END DMA1_Channel1_IRQn 1 */
}
/**
* @brief This function handles DMA1 channel2 global interrupt.
*/
void DMA1_Channel2_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
/* USER CODE END DMA1_Channel2_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc2);
/* USER CODE BEGIN DMA1_Channel2_IRQn 1 */
/* USER CODE END DMA1_Channel2_IRQn 1 */
}
/**
* @brief This function handles ADC1 and ADC2 interrupts.
*/
void ADC1_2_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_2_IRQn 0 */
/* USER CODE END ADC1_2_IRQn 0 */
HAL_ADC_IRQHandler(&hadc1);
HAL_ADC_IRQHandler(&hadc2);
/* USER CODE BEGIN ADC1_2_IRQn 1 */
/* USER CODE END ADC1_2_IRQn 1 */
}So is there any example around of this application or can you solve the doubts (assign the extra DMA buffer and any other information I should consider) I have?
Thanks.
