Ana Matijanovic
Ana Matijanovic

Reputation: 277

How do I generate code in STM32 CUBEMX?

I have downloaded Keil and STM32 CUBEMX (Together with firmware library for my microcontroller).

I don't understand how do I put my c code to see what is really going on? I tried connecting Keil with STM32 Cubemx when creatning new project, but when I go to device there is no STM32 Cube, what should I do?

Upvotes: 1

Views: 5476

Answers (2)

KansaiRobot
KansaiRobot

Reputation: 10052

I just want to add that now there is a STM32 Cube IDE which combines the MX with an IDE, so you can generate the code and go to the editor without any problem. No need to use Keil, or any other IDE

Upvotes: 0

Logan Hunter
Logan Hunter

Reputation: 397

You can't just drop a preexisting project into CubeMX and expect it to sort out what you're trying to do - CubeMX is a code generator for initialization of the hardware, and that's it.

To do what you're trying to do, you need to configure the peripherals as you'd like for your project in CubeMX, have CubeMX generate the project from that (CubeMX can generate projects for a variety of IDEs, including Keil), and then open that project in your IDE and edit in the specifics of your project as you'd like, starting from the generated main function.

Remember to only modify the parts of the generated files between the "USER CODE" comment lines, and not modify those comments if you think you'll ever want to change the project settings you set up in CubeMX - the generator uses those comments to ensure that it doesn't overwrite user code while regenerating the project.

Upvotes: 3

Related Questions