cancel
Showing results for 
Search instead for 
Did you mean: 

ADC1/2 not working over DMA on NUCLEO-H7A3ZI-Q (+Azure RTOS)

tuduce
Associate

Dear community,

I have a NUCLEO-H7A3ZI-Q board with CAN, USART, USB Device and 4 analog inputs. My application is structured using the Azure RTOS, but for ADC testing purposes I am not calling MX_ThreadX_Init() anymore. With the AZRTOS initiated is the same ADC behavior.

The example at https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/NUCLEO-H7A3ZI-Q/Examples/ADC/ADC_DMA_Transfer works, but they only use 1 channel. The board and at least ADC_Channel11 works.

I attached my IOC file, but basically I am using ADC2 (also tried with ADC1) in continuous conversion, DMA circular mode.

I also attached the main.c file. The gist of it:

ALIGN_32BYTES (static uint16_t ADC_VAL[4]);
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
if (hadc == &hadc2) {
ADCfinished = 1; // Set the flag to indicate conversion is complete
}
}

// in main()...
if (HAL_ADC_Start_DMA(&hadc2, (uint32_t *) ADC_VAL, 4) != HAL_OK)
{
Error_Handler();
}

while (1)
{
if (ADCfinished) {
// print the ADC_VAL array
printf("ADC Values: %u, %u, %u, %u\n",
(unsigned int) ADC_VAL[0],
(unsigned int) ADC_VAL[1],
(unsigned int) ADC_VAL[2],
(unsigned int) ADC_VAL[3]);
ADCfinished = 0; // Reset the flag
} // end if
HAL_Delay(250); // Delay for 1 second to allow ADC to stabilize
} // end while

The defined interrupt handler never gets invoked. (If I turn off DMA and use HAL_ADC_Start_IT(), the interrupt is getting called)

By tracing and using some AI magic, I found out that the register DMA1->S0CR->EN is 0 (not enabled). In the HAL_ADC_Start_DMA() function, the call to HAL_DMA_Start_IT() sets this register. However, the very next call (LL_ADC_REG_StartConversion(hadc->Instance);) disables the register.

Can anyone please take a look and tell me what am I missing? What combination of settings are disabling the DMA? Any help is greatly appreciated!

 

Best regards,

Cristian.

 

0 REPLIES 0