cancel
Showing results for 
Search instead for 
Did you mean: 

How to proceed with programming Nucleo-64 using C++

Adev.1
Associate III

Hi all,

I'm an experienced C++ programmer who happen to start learning embedded programming, with a little stuff, like STM32F411RE Nucleo-64 (the board I'm working on mainly) and a blue-pill alongside breadboard and a bunch of wires. I haven't done much in embedded programming since it's hard when you get started alone at home without any instructor.

As an example, using an STM32 C++ project on the STM32CudeIDE, I can blink the LED of the board (when it's connected to my Windows machine) using this code-snipped in the main.cpp file: 

HAL_GPIO_TogglePin (GPIOA, GPIO_PIN_5);

HAL_Delay (3000); 

It's also possible for me to write a few simple functions in that file to, say, generate prime numbers and so forth. Ergo, it should now be evident that my experience is precious little.  

Even though I'm really interested in embedded programming unfortunately whatever series/tutorials I've found on the Web have either been using more embedded stuff that I lack now, or working on complicated projects that are beyond my knowledge. 

I also have found two books:

1) https://www.amazon.co.uk/Programming-STM32-Getting-Started-Nucleo-ebook/dp/B07B6TY9Z9

2) https://www.amazon.co.uk/Real-Time-Efficient-Object-Oriented-Microcontroller-Programming/dp/3662567172/ref=pd_lpo_2?pd_rd_i=3662567172&psc=1

but not sure to read them or not. 

My purpose is to continue learning embedded programming using C++ and the embedded stuff I'm having now (mentioned above) and make progress, if possible. But unfortunately I don't know how to do that! 

What're your pieces of advice for me, please? 

Thanks so much for your time and help. 

8 REPLIES 8
TDK
Guru

Most information online is in C, not C++, but there is not much embedded specific information you need if you are already familiar with C++.

I would avoid dynamic memory allocation on embedded systems, but that is an opinion not a requirement.

If you feel a post has answered your question, please click "Accept as Solution".
Adev.1
Associate III

I try well to keep myself from what is not appropriate to be done using C++ in embedded (line dynamic memory allocation). So considering my background and experience, what do you suggest to me to make progress learning embedded programming better using my board.

For instance, a tutorial embracing a number of related projects, a series, or even a book.

What worked for me was creating projects. Figure out what you want to do and bring it to life. Blink leds, then get UART working through the virtual com port, and move on from there. I do not think books are a good way to learn embedded programming.
HAL is decent for most peripherals if you want to buy into that, but expect some time to learn. Direct register access is also good but generally takes more time than the equivalent Program using HAL.
Converting project to C++ in STM32CubeIDE by right click - conver to c++, then rename main.c to main.cpp. Most libraries are in C, so a solid understanding of working with C and C++ within the same project is required.
Good luck!
If you feel a post has answered your question, please click "Accept as Solution".
Adev.1
Associate III

It's almost impossible to learn those specific topics of embedded programming without a tutor/tutorial for one who has no experience in this case, and the outcome will be quite possibly in vain. That's why I'm sure without a good reference to tell how to lean and do stuff step-by-step, the outcome will be in vain.

For programming it was much more straightforward: Chose C++ as the language, VS as the IDE, and a book of Stroustrup as a reference and made progress quite well little by little.

For embedded programming, too, a course, series, tutorial, reference, book, and so forth is undoubtedly necessary apart from the language and board. I'm sure every embedded programmer has learnt the skill through one of these ways or something alike.

But thank you for your time and remarks.

Nikita91
Lead II

Building an embedded project is not like learning a language like C++. Language is self-sufficient in itself.

For an embedded project you must know the platform you are using intimately. Therefore :

Prepare to spend several months to master all of this.

I started with: https://leanpub.com/mastering-stm32?utm_campaign=mastering-stm32&utm_medium=embed&utm_source=embedder

The part concerning Eclipse is no longer relevant since ST bought TrueSTUDIO and provided STM32CubeIDE. But the rest is easy to read and very informative.

Adev.1
Associate III

Thanks for your good answer.

If I want to firstly go forward with one of those links, as a beginner of embedded programming, which one do you suggest, please?

Nikita91
Lead II

IMO the 1st thing to do is master the tools.

Install IDE

Study a simple example: LED blink as usual

Build your 1st project to blink a LED

The rest is knowledge accumulation and experimentation.

This does not mean that it is enough to write a "good" application. Then the same rigor of design and production is necessary whatever the field: embedded or not.

Adev.1
Associate III

I see.

I'm also not sure if you've read my first post here or not, but just to re-mention, I've installed STM32CubeIDE, STM32CubeMX plus STM32CubeProgrammer. As well as, I've written a simple C++ project to blink the LED of my STM32NucleoF411RE board when it's connected to my Windows machine. Moreover, I'm able to write a typical piece of code in C++ to output a result, just like console applications, and observe that output on the IDE too. I've done these based on self-education and must make progress this way yet.

1) So what I need first is a second project. What do you suggest that I work on as the second project/example/exercise to be a little more advanced than what I did via my board, please?

2) Do you also agree that I start reading the book you started with?

I like to learn stuff and carry them out practically at the same time to acquire the knowledge appropriately.