on 2024-11-27 04:30 AM
This article provides a step-by-step guide on how to configure your STM32H7R/S to transfer ADC converted values in DMA circular mode using STM32CubeMX (version 6.12 is used).
For a complete firmware example, refer to the attached project at the end of the article.
Step 1: Navigate to the [Board Selector] (optionally use the BSP to configure LEDs, user button and virtual com port "VCP")
Step 4: Enable the ADC channels that you need (4 channels are enabled here).
Step 5: Configuration
Create a table of size 64 (or a multiple of 8, for example).
As the processor is a Cortex®-M7, place the table into noncacheable region (ITCM/DTCM memories (@0x0000000/@0x20000000: Not cacheable and only accessible by the Cortex® M7 and the GPDMA/HPDMA).
If the application needs to put DMA buffers in AXI SRAM (starting from @0x24000000), the user must:
Find the pseudo-code below:
/* USER CODE BEGIN PD */
#define ADC_CONVERTED_DATA_BUFFER_SIZE 64
/* USER CODE END PD */
/* USER CODE BEGIN PV */
__IO uint16_t uhADCxConvertedData[ADC_CONVERTED_DATA_BUFFER_SIZE]
__attribute__((section("noncacheable_buffer")));
/* USER CODE END PV */
/* USER CODE BEGIN PFP */
static void MPU_AdjustRegionAddressSize(uint32_t Address, uint32_t Size,
MPU_Region_InitTypeDef* pInit);
static void MPU_Config(void);
/* USER CODE END PFP */
int main(void)
{
MPU_Config(void);
….
HAL_ADC_Start_DMA(&hadc1,
(uint32_t *)uhADCxConvertedData,
ADC_CONVERTED_DATA_BUFFER_SIZE
)
…
…
}
….
For a complete firmware example, refer to attached project.
Results in the debug windows are continuously updated as the ADC DMA transfer is in a circular mode. To check the converted values from the table, suspend the debug and analyze the result from the debug watch window.