Exploring Function Pointers in C Language (Part 3)

Exploring Function Pointers in C Language (Part 3)

Continuing the discussion on pointers in C language, one of the powerful features is the function pointer, which brings unprecedented flexibility and extensibility to your code. What is a Function Pointer? A function pointer, as the name suggests, is a pointer variable that points to a function. It stores the memory address of a function, … Read more

Discussion with an Engineer on His PLC Program Architecture Design

Discussion with an Engineer on His PLC Program Architecture Design

This Monday, a member of the Boto group shared his thoughts on PLC program architecture design. Please refer to the link below: Boto Group Discussion: An Engineer Shares His PLC Program Architecture Design Thoughts Yesterday, I had a Tencent meeting with him to discuss and share his design ideas. 1. Sharing from the Group Discussion … Read more

Master Siemens PLC from Scratch! Create a Highly Functional Cylinder Control Block Using SCL Language for S7-1200

Master Siemens PLC from Scratch! Create a Highly Functional Cylinder Control Block Using SCL Language for S7-1200

Hello everyone! Today we are going to do something very practical—writing a fully functional cylinder control program for the Siemens S7-1200 PLC using SCL language. Even if you have only previously worked with Ladder Diagram (LAD), it doesn’t matter; I will explain it in detail, ensuring you can understand and follow along. Once you do, … Read more

Understanding ‘Callback Hell’ in C Language

Understanding 'Callback Hell' in C Language

Content Hello everyone, I am Bug Jun~Recently, I came across a very interesting term “callback hell”, which refers to endless callback functions that ultimately lead to stack overflow and deadlock. The manifestation of this is multiple layers of nested function pointer callbacks, resulting in poor code readability and maintenance difficulties.Below is a simple example simulating … Read more

An Analysis of Finite State Machines in FPGA Design

An Analysis of Finite State Machines in FPGA Design

Finite State Machine (FSM), also known as a finite state machine, is a mathematical model used to represent a finite number of states and the transitions and actions between these states. It is one of the core concepts in digital logic design, particularly suitable for describing systems with clear sequential processes or those that need … 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

Verilog Functional Module – SPI Master and Slave (02) – Design Concepts and Code Analysis for SPI Master

Verilog Functional Module - SPI Master and Slave (02) - Design Concepts and Code Analysis for SPI Master

Introduction The previous article introduced the four operating modes of SPI and their timing characteristics. I believe everyone has grasped the core principles of SPI communication. This article designs a fully functional 4-wire SPI master using pure Verilog, detailing the module coding concepts and usage precautions, and finally sharing the source code. 1. Module Functionality … Read more

Digital IC Design – Detailed Explanation of Finite State Machines

Digital IC Design - Detailed Explanation of Finite State Machines

Click the blue text to follow us A state machine is a commonly used implementation method in digital IC development using Verilog. A state machine is a universal model for sequential circuits, and any sequential circuit can be represented by a state machine. In the actual digital circuit design process, the choice between using sequential … Read more

How to Retrieve Data from JTAG Daisy Chain Devices

How to Retrieve Data from JTAG Daisy Chain Devices

JTAG is a commonly used interface for debugging devices. When there are many devices, a JTAG daisy chain can be used to save external interfaces, resulting in fewer external connection wires. The connection method is shown in the figure below:When sending and receiving data, it is necessary to determine the data to be received and … Read more

Microcontroller Programming Techniques – State Machine Programming

Microcontroller Programming Techniques - State Machine Programming

Abstract: I wonder if anyone else feels that they can play with microcontrollers and drive various functional modules, but when asked to write a complete set of code, it lacks logic and structure, starting off with random copying and pasting! This indicates that programming skills are still at a relatively low level. So how can … Read more