Miro Samek (@QL)

Dr. Miro Samek is the CEO of Quantum Leaps (state-machine.com) and an expert on programming modern real-time embedded (RTE) systems. He is the author of practical books and articles about UML state machines, active objects (actors), and real-time embedded frameworks (RTEFs). Since 2013, Miro has been teaching the popular “Modern Embedded Systems Programming” course on YouTube. His industry experience ranges from GE Medical Systems to Silicon Valley companies specializing in GPS technologies. His software continues to power billions of embedded devices. Miro earned his Ph.D. in nuclear physics at GSI (Darmstadt, Germany).

Are We Shooting Ourselves in the Foot with Stack Overflow?

Miro Samek September 8, 20234 comments

Most traditional, beaten-path memory layouts allocate the stack space above the data sections in RAM, even though the stack grows “down” (towards the lower memory addresses) in most embedded processors. This arrangement puts your program data in the path of destruction of a stack overflow. In other words, you violate the first Gun Safety Rule (ALWAYS keep the gun pointed in a safe direction!) and you end up shooting yourself in the foot. This article shows how to locate the stack at the BEGINNING of RAM and thus point it in the "safe" direction.

NULL pointer protection with ARM Cortex-M MPU

Miro Samek July 16, 2023

This post explains how you can set up the ARM Cortex-M MPU (Memory Protection Unit) to protect thy code from dragons, demons, core dumps, and numberless other foul creatures awaiting thee after thou dereference the NULL pointer.

Patterns of Thinking: Metaphors in Programming

Miro Samek May 14, 20224 comments

Several years ago, I once attended an “Object-Oriented Analysis and Design” training. As most such courses go, the instructor began with brushing up on the fundamental OO concepts. When explaining inheritance, the instructor spontaneously compared inheriting from a class to passing traits from parents to the offspring in a family. At first, this “family tree” metaphor seemed to make a lot of sense and most attendees nodded approvingly. However, when the instructor discussed...

Embedded Programming Video Course Shows How OOP Works Under the Hood

Miro Samek September 29, 2019

If you'd like to understand how Object-Oriented Programming (OOP) really works under the hood, here is a free video course for you:

OOP part-1: Encapsulation: This first lesson on Object-Oriented Programming (OOP) introduces the concept of Encapsulation, which is the ability to package data and functions together into classes. You'll see how you can emulate Encapsulation in C, what kind of code is generated, and how to debug such code. Next, you will translate the C design into C++ using...

Embedded Programming Video Course Teaches RTOS

Miro Samek January 20, 2019

If you'd like to understand how a Real-Time Operating System (RTOS) really works, here is a free video course for you:

RTOS part-1: In this first lesson on RTOS you will see how to extend the foreground/background architecture from the previous lesson, so that you can have multiple background loops running seemingly simultaneously.:

RTOS part-2: In this second lesson on RTOS you will see how to automate the context switch process. Specifically, in this lesson, you will start building...

Embedded Toolbox: Source Code Whitespace Cleanup

Miro Samek August 5, 2017

In this installment of my "Embedded Toolbox" series, I would like to share with you the free source code cleanup utility called QClean for cleaning whitespace in your source files, header files, makefiles, linker scripts, etc.

You probably wonder why you might need such a utility? In fact, the common thinking is that compilers (C, C++, etc.) ignore whitespace anyway, so why bother? But, as a professional software developer you should not ignore whitespace, because it can cause all sorts...

Embedded Toolbox: Windows GUI Prototyping Toolkit

Miro Samek July 7, 20172 comments

In this installment of my "Embedded Toolbox" series, I would like to interest you in the free Windows GUI Toolkit called QWin for prototyping, developing and debugging embedded C or C++ code on Windows.

If you work on devices with non-trivial user interfaces consisting of LCDs (segmented or graphic), buttons, LEDs, etc., QWin could be just the tool for you. It has improved my productivity in such projects dramatically. I personally consider it a gem in my "Embedded...

Embedded Toolbox: Programmer's Calculator

Miro Samek June 27, 20178 comments

Like any craftsman, I have accumulated quite a few tools during my embedded software development career. Some of them proved to me more useful than others. And these generally useful tools ended up in my Embedded Toolbox. In this blog, I'd like to share some of my tools with you. Today, I'd like to start with my cross-platform Programmer's Calculator called QCalc.

I'm sure that you already have your favorite calculator online or on your smartphone. But can your calculator accept...

Modern Embedded Systems Programming: Beyond the RTOS

Miro Samek April 27, 20167 comments

An RTOS (Real-Time Operating System) is the most universally accepted way of designing and implementing embedded software. It is the most sought after component of any system that outgrows the venerable "superloop". But it is also the design strategy that implies a certain programming paradigm, which leads to particularly brittle designs that often work only by chance. I'm talking about sequential programming based on blocking.

Blocking occurs any time you wait explicitly in-line for...

Cutting Through the Confusion with ARM Cortex-M Interrupt Priorities

Miro Samek February 26, 2016

The insanely popular ARM Cortex-M processor offers very versatile interrupt priority management, but unfortunately, the multiple priority numbering conventions used in managing the interrupt priorities are often counter-intuitive, inconsistent, and confusing, which can lead to bugs. In this post I attempt to explain the subject and cut through the confusion.

The Inverse Relationship Between Priority Numbers and Urgency of the Interrupts

The most important fact to know is that ARM...

If this is just a toy project for learning, go ahead. But don't do this in a real thing.
The results of the EmbeddedRelated quiz on integer arithmetic in C are quite interesting (and will be even more interesting with more participants!) The success...

Re: Modeling and Code Generation now called "Low-Code"

Reply posted 2 years ago (05/15/2022)
Yes, to me also the most worrisome is the low-code's promise to "allow users with no formal knowledge of coding or software development to create applications for...
I've recently listed to the webinar "Benefits of low code development in embedded systems" by IAR Systems. It turns out that "Low-Code" is the old modeling with...

Re: HardFault during erasing Flash in debug mode

Reply posted 3 years ago (07/09/2021)
Most likely you still have some access to ROM, perhaps your code reads some constants in ROM (e.g., strings, etc.) Also, there might be still calls (perhaps indirect)...

Re: Embedded C - Linking obj file

Reply posted 4 years ago (11/12/2020)
The information you provide is incomplete. For example, which toolchain are you using?If this is GCC, are you using the `-ffunction-sections` or `-fdata-sections`...

Re: Assert() If You Test Pre/Post Conditions

Reply posted 4 years ago (11/06/2020)
> If there's a framework you use that can play nicely with assertions, I'd appreciate a recommendation.Yes. If you are willing to go a bit off the beaten path,...

Re: Assert() If You Test Pre/Post Conditions

Reply posted 4 years ago (11/05/2020)
I'm always glad to see discussion about assertions in embedded code, because, as Bertrand Meyer (the inventor of Design by Contract) said: "... this puts the whole...

Re: When is a State Machine not a State Machine?

Reply posted 4 years ago (07/21/2020)
Yes, I'm also glad that this issue came up. This is just an example of a bigger issue of the fuzzy terminology of our discipline. The other terms causing constant...

Re: When is a State Machine not a State Machine?

Reply posted 4 years ago (07/21/2020)
Of course, you can hold the viewpoint that "everything is a state machine". The CPU is a state machine... The universe is a state machine (perhaps an "implicit"...

Re: When is a State Machine not a State Machine?

Reply posted 4 years ago (07/20/2020)
Hell No! The code you are showing is NOT a state machine. In fact, it is an antithesis of a state machine.My whole recent presentation at the Embedded Online Conference uses...
The answer to your question and more is nicely explained by Nigel Jones in his blog on Embedded Gurus
I think that this is what the C99 "fast" integers are for. Use uint_fast8_t when 8-bits of dynamic range are sufficient. Use uint_fast16_t if you need at least...

Re: Event Driven Frameworks

Reply posted 4 years ago (01/14/2020)
You might want to take a look at the event-driven QP Real-Time Embedded Frameworks. In full disclosure: I run the company, Quantum Leaps, that makes and licenses...

Re: How does an embedded system OS work? LPC3250 ARM9

Reply posted 5 years ago (05/09/2019)
It seems that you are trying to do too much in the very first step. You are moving from bare-metal to operating system and you immediately want to deal with networking,...

Re: Stack - interrupt, function call?

Reply posted 5 years ago (01/04/2019)
The YouTube video-course "Modern Embedded Systems Programming" explains the concepts you are confused about. Specifically, here are the lessons that answer your...

Re: Low level programming

Reply posted 5 years ago (12/03/2018)
One resource you might want to try is the "Modern Embedded Systems Programming" video course on YouTube. This course uses the modern ARM Cortex-M microcontroller...

Re: self-learning embedded curriculum

Reply posted 6 years ago (09/19/2018)
Thanks for mentioning my "Modern Embedded Systems Programming" course on YouTube. The complete playlist of this course is available here:https://www.youtube.com/playlist?list=PLPW8O6W-1ch...The...

Re: Cooperative scheduling

Reply posted 6 years ago (06/01/2018)
As already mentioned in the OP, cooperative scheduling is especially applicable to run event-driven systems of cooperating state machines. In that case, you don't...

Re: Microcontroller books suggestions

Reply posted 7 years ago (08/24/2017)
Hi Steve Yes, I teach the video course. No, I'm not located in Australia. No, I don't offer training or other services. --MMS

Re: Microcontroller books suggestions

Reply posted 7 years ago (08/23/2017)
I would recommend the "Modern Embedded Systems Programming" video course on YouTube. The course is intended for newcomers to the embedded software field and is...

Re: Startup file and linker script

Reply posted 7 years ago (08/07/2017)
You might want to watch the "Modern Embedded Systems Programming" video course. Specifically, lessons-13, 14, and 15 talk about startup code and linker scripts....
I have Rabbit 3000 TCP/IP development kit from Z-World to donate. Would that do? 
@Ivan Cibrario Bertolotti: I absolutely agree that the debate between proponents of shared-state concurrency and event-driven, Erlang-style concurrency has been...
The recommendation to use "accessor functions" (a.k.a., "getters and setters" in OOP) is rather misguided, because it really does not "encapsulate" anything in terms...
In my experience, C++ makes an excellent programming language for real-time embedded (RTE) systems. However, as with all C-like languages, for safety-critical...

Use this form to contact QL

Before you can contact a member of the *Related Sites:

  • You must be logged in (register here)
  • You must confirm you email address