2025-03-21 1:20 PM - last edited on 2025-04-02 3:13 AM by Sarra.S
Hey everyone, this is my first post here on this forum.
I'm working with an STM32H723VET6 on the VSCode environment with CMAKE, and i'm coming across a peculiar issue; with a breakpoint and even a GPIO toggle on the HAL_ADC_ConvCpltCallback function, neither are ever seen to call it.
I am just using ADC1 to scan convert across 4 channels via DMA with timer automation. I have no MPU or cache enabled whatsoever either.
Very importantly, I have tried something very similar to this in CubeIDE with no issue. CubeMX here is generating code to my local project and using the Cube CLT via VSCode to build and debug my code, it works without issue until I start to mess with bits of ADC HAL code.
I've followed this great guide (https://www.youtube.com/watch?v=_K3GvQkyarg), and I've attached screenshots of peripheral configuration:
My APB1 Timer bus is being run at 264MHz and my ADCs are being fed 150MHz clock. Timer 3 should be converting at a rate of roughly 1kHz, to which I do not suspect to be an issue with DMA bandwidth at all.
Here is relevant code from my main.c:
#include "main.h"
#include "adc.h"
#include "dma.h"
#include "memorymap.h"
#include "tim.h"
#include "gpio.h"
// ...
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define SIZE 128
/* USER CODE END PD */
// ...
/* USER CODE BEGIN PV */
volatile uint16_t adcData[SIZE];
/* USER CODE END PV */
//...
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef * hadc) {
HAL_GPIO_TogglePin(test_GPIO_Port, test_Pin);
}
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_TIM3_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
Error_Handler();
if(HAL_ADC_Start_DMA(&hadc1, (uint32_t *) adcData, SIZE) != HAL_OK)
Error_Handler();
if(HAL_TIM_Base_Start(&htim3) != HAL_OK)
Error_Handler();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(100);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Weirdly, none of my error handler function calls are triggered when checked via breakpoints, and the While(1) loop proceeds as normal with HAL_Delay working. I've followed recommended guidance to set up this environment and have had no issues until trying to get ADC HAL code to work here, it's never been an issue for me in CubeIDE either. I've also attached here a screenshot of my .ioc project configuration:
If any of you folks have potential ideas of what could be happening or pointers forward, that would be greatly appreciated.
2025-08-11 1:25 AM
Hello @mylo_calibre,
Since your project runs in STM32CubeIDE with no issue, the issue is likely from VSCode environment.
Have you been able to run/ debug an existing CubeFW project using VSCode?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-08-23 1:22 PM
Hey I am actually experiencing the same problem.
Mine is STM32H725RGV6 and it works fine with CubeIDE and suprisingly, it works with the 2.1.1 version of the extension but not on the latest 3.5.1.
I found out that DMA for some reason just doesn't work. I have a fresh project with DMA and UART, which both failed to work at all. Calling the blocking and interrupt based functions works fine but not DMA.
I inspected the memory buffer for the ADC, it didnt even start filling the buffer.
I compared the difference between the source files of the cubeide with vscode version and theres not really any difference apart from cmake vs cubeide
What could possibly be different that may have caused this? Please let me know if you need any more details
2025-10-01 9:12 PM
Okay, replying to this thread after quite some time as I've finally gotten motivation to work on this project again!!
Since then, I've been working on some other bits of firmware in the same VSCODE environment, I've even managed to get an entire SPI display driver working on an SSH1106 OLED. Everything still compiles and breakpoints beautifully in VSCODE. It seems though that this ADC + TIM + DMA issue still persists though.
I came back around to trying the ADC + TIM + DMA issue, with a much simpler, single-adc (ADC1) use case. I'm in independent mode, scanning across eight channels with a 1Hz timer in nearly the exact same configuration as in the Youtube video i posted at the beginning of the link.
To my dismay, the following configuration didn't work in VSCODE but did in cubeIDE, once again:
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_SPI3_Init();
MX_ADC1_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK)
Error_Handler();
if(HAL_ADC_Start_DMA(&hadc1, (uint32_t *)in_buff, sizeof(in_buff)) != HAL_OK)
Error_Handler();
HAL_TIM_Base_Start_IT(&htim3);
I do absolutely agree now that this is some issue with my VSCODE configuration. I tested this by taking the .ioc file, copying it into a new directory, and creating a cubeIDE project from it directly. I also copied the EXACT same main.c file and ran code generation with it. In my live expressions on VSCODE, I see absolutely no activity, but on the mirrored cubeIDE project I just made again, it works perfectly.
I should also say that this is not neccessarily an issue with the VSCODE live expressions viewer, as I've configured my launch.json file correctly and it works for any other dummy expression I test. See below:
CubeIDE live expressions:
VSCODE:
I've added a GPIO toggle to an on-board LED within the timer interrupt (again I've slowed this down to 1Hz for testing). Despite visually confirming the timer is working in both VSCODE and cubeIDE, it seems as though the ADC on the VSCODE side is simply never being triggered by the timer or something similar.
If you folks are able to lend a hand to help me solve this issue, I'd grealty appreciate it; either here on the forum or privately. I'd like to emphasize again that parity is completely maintained between both the main.c file and .ioc file in both environments, at least as much as I can see.
As @hakeem mentioned below in the thread, the only real difference would be the cmake vs cubeIDE build structure.
Best,