Why C++ is Rarely Used in Microcontroller Development

Why C++ is Rarely Used in Microcontroller Development

When it comes to embedded programming, many people’s first impression is C/C++. However, you will find that microcontroller development is mostly done in C, with very few using C++. So, can C++ be used for microcontroller development? The answer is definitely yes. Below, based on Keil and STM32, I will describe how to use C++ … Read more

Master the ‘Black Magic’ of C Language Macros in 5 Minutes! `#` and `##` Double Your Code Efficiency

Master the 'Black Magic' of C Language Macros in 5 Minutes! `#` and `##` Double Your Code Efficiency

Are you still using the most basic<span>#define PI 3.14</span>?80% of embedded engineers have not truly harnessed the power of macros! When you see meaningless entries in your debug logs like<span>val=123</span>, when your code is filled with repetitive type conversions, and when you want to implement generic operations but feel helpless—today, these two symbols willrevolutionize your … Read more

Sharing an Embedded Programming Template

Sharing an Embedded Programming Template

Input Events to State Machine #include "stdio.h" #define EXECUTE_VOID(func) {if((func)!=NULL) (func());} typedef void(*select_machine_t)(void); typedef enum _event_index{ event_index_1 = 0, event_index_2, event_index_3, event_index_end} event_index_e; typedef enum _status_index{ status_index_1 = 0, status_index_2, status_index_end} status_index_e; void machine_1(void); void machine_2(void); void machine_3(void); void machine_4(void); select_machine_t select_machine[event_index_end][status_index_end] = { {machine_1, machine_2}, {NULL, machine_3}, {machine_4, NULL}}; void machine_1(void){ printf("machine_1\r\n"); } void … Read more

Advanced Embedded Programming | JavaScript Implementation of CRC16-MODBUS Function Code (Is DeepSeek Wrong?!?)

Advanced Embedded Programming | JavaScript Implementation of CRC16-MODBUS Function Code (Is DeepSeek Wrong?!?)

01Introduction: Let’s start with the correct code. We will use a six-byte array for testing: [0x0a, 0x03, 0x02, 0x00, 0x00, 0x16]. 02Function and Results 1. Function // Example with 0a 03 02 00 00 16 var buffer = [0x0a, 0x03, 0x02, 0x00, 0x00,0x16]; // Call the function to calculate the CRC checksum var crc = … Read more

Six Common Data Structures in Embedded Programming

Six Common Data Structures in Embedded Programming

Today, embedded systems are increasingly applied in various fields such as smart homes, smart healthcare, industrial automation, and intelligent transportation. In the development of embedded systems, data structures are an essential knowledge point. This article will introduce several common data structures in embedded programming, including arrays, stacks, queues, heaps, hash tables, and linked lists. 1. … Read more

Why C++ is Rarely Used in Microcontroller Development?

Why C++ is Rarely Used in Microcontroller Development?

Author | strongerHuang WeChat Official Account | strongerHuang When it comes to embedded programming, many people’s first impression is C/C++. However, you will find that microcontroller development is mostly done in C, with very few using C++. So, can C++ be used for microcontroller development? The answer is definitely yes. Based on Keil and STM32, … Read more

A Comprehensive Guide to C Language Pointers: Easy to Understand and Detailed!

A Comprehensive Guide to C Language Pointers: Easy to Understand and Detailed!

Today, I will explain pointers. From basic to advanced, this article will combine practical applications to help you learn pointers while understanding what experts use pointers for!Long article warning! The entire text is about 5200 words, and this article is enough to learn pointers!Many people, like me when I first learned C language, are afraid … Read more

MicroPython Embedded Programming Tools

MicroPython Embedded Programming Tools

MicroPython is one of the most popular topics in open-source hardware in recent years, invented by Professor Damien George from the University of Cambridge, and is essentially a version of the Python language used for embedded programming.One of the challenges in embedded programming is that programmers need to focus not only on the software but … Read more

Embedded Programming: Fast Context Switching Based on cpost with Code Link at the End

Embedded Programming: Fast Context Switching Based on cpost with Code Link at the End

The demands of embedded development programming are ever-changing. To achieve system stability and code reusability, high cohesion and low coupling must be maintained.It is generally believed that time-consuming operations cannot be executed within interrupts, as this would affect system stability. For programs with an operating system, interrupt handling can be divided into two parts through … Read more

Methodology for Building Embedded Programs from Code and Toolbox for Hardware Debugging

Methodology for Building Embedded Programs from Code and Toolbox for Hardware Debugging

How to Build Embedded Programs and Find Documentation 1. Define the Purpose For example, if I want to configure a peripheral, I need to first understand how to drive this peripheral, its structure, enumerations, and what methods are available, etc., and whether there are examples to refer to. 2. Find the Core Structure <span>esp-hal</span> library … Read more