Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
3 years, 7 months ago.
Import mbed-dev to a stm32cube mx project
Hi, I am using Keil as an IDE and it work great for debugging mbed-os exported projects.
Currently I am working with a custom target, based on the NUCLEO-F446ZE, but with different clock settings. Since the custom board was clock-incompatible with the original target, and i needed usb-otg support, I was forced to start using stm32cubemx for generating startup code.
But most of my code for my application was developed during the prototyping stage using mbed-dev libraries and c++ classes, like Serial, InterruptIn, Ticker, and many others.
I tried many ways to import mbed-dev to a stm32cubemx generated project on Keil, but nothing works properly. I managed to compile the code with no errors, but after flashing, most of mbed objects don't work properly.
i suppose i should post code, or something that could help someone help me, but i am hopping that someone in here had this same problem and found a solution.
I have tried to approaches, but had no success. Approach 1:
- Generate a STM32cubemx project with all the peripherals and clock configs i need.
- Migrate the project form C to C++.
- Add USB suport as a CDC device. (Everything works till here)
- Import mbed-dev (minus the files that are already in the project).
- Add InterruprIn and wait_us calls to main()
After compiling and flashing, InterruptIn get stuck during initialization and wait_us() also get stuck.
- Generate a mbed project (Blinky) and export it to mbed (works ok)
- Replace mbed-dev/targets/target_stm files with new ones.
Also interruptIn get stuck during initialization and wait_us() also get stuck.
It seems to me that something must be modified in the cube files to work with mbed-dev libraries. I have some ideas where to start looking, but I am hoping someone had this same problem in the past and knows how to deal with it.
Any help would be much appreciated.
As a side comment, mbed is a great tool for prototyping, but when moving forward to a custom-board as a final product, many issues arise. This is one of the many issued i had encountered when migrating from a development board to a custom-board. If i had the time to re-write the code that was written with mbed-dev and use raw HAL-CMSIS code, i would abandon mbed altogether.
Any comments or piece of advice on this would also be appreciated.
3 years, 7 months ago.
You can add code snippets or files generated by the stm32cube mx to your mbed project. Have a look at the Internal_Temperature_F103RB demo and the CANnucleo library. You can also change the clock settings in your mbed application based on the code generated in frame of a stm32cube mx project. Have a look at the STM32F103C8T6_Hello demo and the mbed-STM32F103C8T6 library. But then, to avoid initialization issues, I recommend you to create your mbed objects in main after the system clock has already been set, as for instance in this STM32F103C8T6_ILI9341 demo.