Hi Forum,
i've really run into a strange problem here. I'm trying to program the DMA for my STM32H750 MCU. When using the HAL Drivers from STM, everything is done by using peripheral handlers, which are declared in the source files generated by CubeMX.
When using the Timers and the UART, everything works fine. But now, i've get an "undeclared (first use in this function)" error when trying to call HAL_DMA_Start function with the "hdma_adc1" handler. When stepping through the code with the debugger, i can clearly see that the handler is declared and even initialized. And even more strange: when clicking on the hdma_adc1 in the function call (which is underlined red for being the error) i can jump to declaration without any problem. So why can i jump there when the compiler says, that it is not declared anywhere?
Here is some code:
This is the Init section at the beginning of my code. As seen with the HAL_TIM_OC_Start, the dereferenced handlers are used to call the functions f.ex. "&tim2".
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_ADC3_Init();
MX_DAC1_Init();
MX_SPI1_Init();
MX_TIM2_Init();
MX_TIM3_Init();
MX_UART4_Init();
MX_USB_OTG_FS_PCD_Init();
MX_ADC2_Init();
MX_TIM1_Init();
MX_SPI2_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_2); // Start timer for heartbeat LED
USR_send_Board_Info();
HAL_Delay(2000);
HAL_DMA_Start(&hdma_adc1, (uint32_t)&(hadc1.Instance->DR), (uint32_t)&samples[0], 1999);
HAL_ADC_Start(&hadc1);
The compiler marks the line which calls HAL_DMA_Start(&hdma_adc1,...).
hdma_adc1 gets declared in the source file, which includes the MX_ADC1_INIT():
/* Includes ------------------------------------------------------------------*/
#include "adc.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
ADC_HandleTypeDef hadc3;
DMA_HandleTypeDef hdma_adc1;
/* ADC1 init function */
void MX_ADC1_Init(void)
{
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_16B;
.
.
.
The type of hdma_adc1 is (as seen) "DMA_HandleTypeDef". When checking the HAL_DMA_Start() function, this type should be totaly fine:
/**
* @brief Starts the DMA Transfer.
* @param hdma : pointer to a DMA_HandleTypeDef structure that contains
* the configuration information for the specified DMA Stream.
* @param SrcAddress: The source memory Buffer address
* @param DstAddress: The destination memory Buffer address
* @param DataLength: The length of data to be transferred from source to destination
* @retval HAL status
*/
HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
{
HAL_StatusTypeDef status = HAL_OK;
.
.
.
So what is going on here? Is this a compiler bug? If there were some typos or anything similar, I shouldn't be able to jump to declaration, didn't I?
Please let me know if you need more code to get a better understanding.
Thanks in advance
Kind Regards
Tony