cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube MX, VScode setup

ROVguy
Associate

Hello.
I'm having issues with STM32CubeMX and VScode setup. I have the STM32 VScode extension installed and all the extras that were required as per this page ( https://marketplace.visualstudio.com/items?itemName=bmd.stm32-for-vscode ). I generate a make file for the blue pill based on the STM32F103C8T6 IC. When I open the code in VScode I immediately see errors starting with (main.h: No such file or directory 20 | #include "main.h")
There are other errors starting with unknown type name 'RCC_OscInitTypeDef' | RCC_OscInitTypeDef RCC_OscInitStruct = {0};
'RCC_CLOCKTYPE_HCLK' undeclared (first use in this function) | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK


Any suggestions on how to set this up so these errors are permanently resolved?

2 REPLIES 2
RhSilicon
Lead

I found these videos:

https://www.youtube.com/watch?v=PxQw5_7yI8Q

https://www.youtube.com/watch?v=xaC5oWwzOt0

https://www.youtube.com/watch?v=7stymN3eYw0

Note: I've already used vscode a few times, but I think it's better to use the STM32CubeIDE with the STM32 MCUs, ST is already making an effort to keep it updated and fix the bugs, and the people here on the forum have more knowledge in this STM32CubeIDE. It may take a while to get used to the STM32CubeIDE if the programmer is not familiar with the Eclipse IDE, but I think it's worth it. In the end the generated code should be similar too.

It's a matter of taste. I prefer vscode with https://marketplace.visualstudio.com/items?itemName=bmd.stm32-for-vscode plugin (which came before the ST own plugin). Projects are Makefile based and there is much less magic behind the curtain compared to STM32CubeIDE/Eclipse.

Are those error just squiggles in the editor? It may take a while until IntelliSense has picked up all neccessary include files.

Edit: this process is done by the Makefile tools https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools which should be installed too.

hth

KnarfB