Essential Microcontroller Programming Skills: A Transformation Guide from Beginner to Expert

Essential Microcontroller Programming Skills: A Transformation Guide from Beginner to Expert

Hello everyone! Today, I want to share not just dry coding rules, but 6 practical skills that can help your microcontroller projects succeed and double your code efficiency. These experiences come from my years of lessons learned from mistakes, specifically addressing the “program runs but is not user-friendly” issues! 1. Project Planning: Draw the Map … 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 machine_2(void){ printf("machine_2\r\n");} void … Read more

Embedded Programming: How to Implement State Machine Design in C Language?

Embedded Programming: How to Implement State Machine Design in C Language?

I am Lao Wen, an embedded engineer who loves learning. Follow me, and let's become better together! The state machine pattern is a behavioral pattern that effectively implements state transitions through polymorphism. Unfortunately, in embedded environments, we often have to write pure C code, and we also need to consider reentrancy and multitasking requests, which … Read more

The Most Suitable Communication Protocol for Microcontrollers: How to Design It?

The Most Suitable Communication Protocol for Microcontrollers: How to Design It?

In communication design, considering the flexibility of the protocol often leads to designing protocols as “variable length”. An example is shown in the figure below: the communication protocol frame of the Ruimi LoRa terminal. If a system receives the above “variable length” protocol frame, there will be a challenge—how to efficiently receive and parse it. … Read more

State Machine Programming in Industrial Control Systems: Design Concepts and Implementation Strategies

State Machine Programming in Industrial Control Systems: Design Concepts and Implementation Strategies

Click the little blue text to follow! A few days ago, a colleague who works with coding for inkjet printers came to me, saying that his device often “stalls”; sometimes the print head works normally, but at other times it suddenly stops and inexplicably enters cleaning mode. Seeing his worried expression, I guessed it right—this … Read more

State Machine Programming Development: Methodologies for Building Reliable Industrial Control Systems

State Machine Programming Development: Methodologies for Building Reliable Industrial Control Systems

Click the blue text to follow! Yesterday, a friend working on a packaging line complained that their control system frequently malfunctioned—sometimes the conveyor belt would suddenly stop, and sometimes the packaging would not execute in order. I asked him, “Have you used state machine programming?” He looked puzzled. Many beginners overlook this powerful tool, so … Read more

Learning JTAG Standard (IEEE1149.1) – Part 2

Learning JTAG Standard (IEEE1149.1) - Part 2

TAP controller The TAP controller is a finite state machine that transitions states based on the TMS signal at the rising edge of TCK, generating control signals to operate the JTAG circuit. The state transition diagram of the TAP controller is shown below: Each state is described as follows: Test-Logic-Reset: The test logic is disabled, … Read more

C# State Machine: A Tool for Parsing Binary Protocols

C# State Machine: A Tool for Parsing Binary Protocols

C# State Machine: A Tool for Parsing Binary Protocols Hello everyone! Today I want to share a very useful technique – using a state machine to parse binary protocols. In our work, we often need to handle various communication protocols, such as serial communication and network protocols. Using a state machine to tackle these problems … Read more

Microcontroller Programming Techniques – State Machine Programming

Microcontroller Programming Techniques - State Machine Programming

Follow and star the official account to reach exciting content directly. Source: Play with Embedded Systems Author: Alicedodo Abstract: I wonder if everyone has this feeling, that you can play with microcontrollers and drive various functional modules, but when asked to write a complete set of code, there is no logic or framework, you just … Read more

Embedded Development: State Machine + Event-Driven Framework

Embedded Development: State Machine + Event-Driven Framework

Concept of Event-Driven There are many examples of event-driven in life, like sneaking a nap during self-study while the teacher is not watching. We all went through high school, which was tough. High school students feel that sleeping is the most luxurious thing in the world; sometimes, you can even fall asleep while standing! The … Read more