When developing with C or C++ an application, then you mostly focus on your own code. You don’t want to bother with the details how input/output functions like printf() or scanf(), and you might just use these functions and helpers and that’s it.
The implementation is part of the ‘C Standard Library’ (or C++ Standard Library). In the world of Linux, this is usually the ‘glibc’ or ‘GNU C Library, and one usually link with ‘libc’. That provides the implementation of printf(), or use ‘libm’ if using math functions like sin() or cos().
In the embedded world, things are much more complex, with plethora of choices, for example in the MCUXpresso IDE:
With the war in the Ukraine, energy prices in Europe reached new record levels. This initially affected the gas price which does not affect me directly. But it had a big impact on the price for electrical energy too. In my village, the price for electrical energy is now at 0.45 CHF/kWh, starting October 1st 2022. It is twice as much as what it used to be, and three times more what it used to be the price for the energy at night time.
Saving energy always makes a lot of sense, now even more, both for the environment and directly saving money. Luckily, I started thinking about optimizing the electrical energy used in my house back in 2021, and now in 2022 it really pays off: The daily average of 16 kWh/day (including heating and cooling) came down to 7 kWh/day, or from 4.5 MWh/year down to 2.4 MWh/year, or a reduction of 47%.
There were different areas contributing to this very positive result:
The above graph shows the changes in the different categories, from 2021 (blue, 4.5 MWh) to 2022 (orange, 2.4 MWh).
If you are in the electronics or microcontroller business: you very well know the problems with chip and silicon availability. What was supposed to last maybe for a few months starting with COVID-19 is still a problem in 2022: chips are not available or the price has skyrocket.
We at the Lucerne University are using NXP Kinetis micro controllers which seem to be affected by the silicon shortage somewhat more than any other devices? When looking that the usual sources, it was clear some are still available, but in a rather exotic WLCSP package. So the question is: can it be useful?
Tool chains like the GNU compiler collection (gcc) have a plethora of options. The probably most important ones are the ones which tell the compiler how to optimize the code. Running out of code space, or the application is not performing well? Then have a look at the compiler optimization levels!
However, which one to select can be a difficult choice. And the result might very well depend on the application and coding style too. So I’ll give you some hints and guidance with an autonomous robot application we use at the Lucerne University for research and education.
The silicon shortage is still going on. While the NXP Kinetis KE devices might not be my first choice, they still seem to be available, in at least in lower quantities. This has been recognized by others, as I’m getting more and more questions and requests for the KE and KV family. This is why I un-dusted my old FRDM-KE02Z to be used with the latest MCUXpresso SDK and IDE.
And in case you want to use that board or device with semihosting, I have you covered.
I’m now in the middle of the university fall semester exam season with writing exams and grading student work, and the same time the new semester courses need to be prepared. With the global silicon and board shortage, this will be again a challenge to equip all the labs with the needed infrastructure. The good thing is that there is no shortage on software and tools side of the infrastructure: NXP released last week their new flagship Eclipse based IDE: the MCUXpresso IDE 11.5.0. Time to check it out for the upcoming lectures and classes….
Spoiler Alert: It has a new view for FreeRTOS lovers, plus new features for energy/power measurements!
In Spilling the Beans: C/C++ Header Files, I touched on interfaces and the difference between external and internal linkage. This article has a focus on internal linkage with using the static keyword in C.
So this might be a programming language refresher, in case you are clear about the difference between declaration and definition, or if you are wondering about internal or external linkage in C.
After the release of the NXP MCU-Link debug probe, there have been hints in the Eclipse based MCUXpresso IDE that there must be another one coming. And indeed: another and more powerful debug probe is now available: the MCU-Link Pro. It is not only a debug probe but a power/energy measurement tool too, including an extra LPC804 mikrocontroller which can be used for all kind of things, like automation or scripting.
It is interesting to see that some aspects (mostly unintended) can stimulate lots of good and fruitful discussions. So this happened with “Spilling the Beans: Endless Loops” (recommended to read 🙂 where using (or not using) volatile for inline assembly created thoughts which warrant an article on that subject.
The volatile qualifier in C/C++ is misunderstood by many programmers, or wrongly used.
Still, ‘volatile’ is very useful if you know what it means for the compiler and what is good use of it.