Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


C++ programing when generating from CubeMX

Hello!
I’m trying to write a program in C++ using Cube MX.
1. When generating, then importing, adding my own code in C, it works fine.
2. When choosing “Convert to C++”, there are some errors.

First error:
I use a timer in my code. At the end of the timer initialization, there is a function
HAL_TIM_MspPostInit(&htim1);. When in C, there is no problem. When converting
to C++, it gets a compilation error: undefined reference to HAL_TIM_MspPostInit(TIM_HandleTypeDef*)
CubeMX generates the call, but not the function itself, and the function is external.

Second error:
In stm32f7xx_hal_msp.c, it says undefined reference to Error_Handler.
In the same file, Error_Handler is declared as external, and the definition is in main.c (renamed .cpp).

Can anyone help me to fix these errors?

Thanks,
Dora.

Dora
Research on the internet - Calling C functions from C++ code.
This sounds like its your problem.
You need to wrap your C function declarations in:
extern “C” ;


Hello Robert!

Sorry for the delay. And thanks for your reply.
Indeed, there were extern “C” in all the generated code, but not around the
extra fucntions added by the code generator around (for exempl) the
static void MX_something functions. Could be a good idea to modify the
code generator so that it addes the extern “C” around the generated C
functions declarations.

Just in case somebody bumps into the same problem: put the ifdef
and endif statements in the user code areas around the functions so that
it doesn’t get erased if you regenerate.

Thanks again!

Dora


 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs