C Language – The Lifecycle of Variables: How to Retain the Previous Value?

C Language - The Lifecycle of Variables: How to Retain the Previous Value?

First, please review the previous article that used the counter in 【C Language】 – What is a Function Callback, and How to Implement It? Have you ever thought about: How does the count value retain its previous value in the next cycle? After entering the next cycle, will the variable value still exist before the … Read more

Resolving Linker Errors: Multiple Definition of `yylloc` in Embedded Linux

Resolving Linker Errors: Multiple Definition of `yylloc` in Embedded Linux

Resolving Linker Errors: Multiple Definition of <span>yylloc</span> When compiling the Device Tree Compiler (DTC) tool, developers often encounter the following linker error: /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here This error indicates that the linker has found a duplicate definition of the global variable <span>yylloc</span> in <span>dtc-parser.tab.o</span> and <span>dtc-lexer.lex.o</span>. This article will … Read more

Scope Rules in C Language

Scope Rules in C Language

In any programming language, the scope is the area in which a variable defined in the program exists; outside of this area, the variable cannot be accessed. In C language, there are three places where variables can be declared:Local variables inside functions or blocksGlobal variables outside of all functionsFormal parameters in function definitionsIn the last … Read more

Should Global Variables Be Recommended in Embedded Software?

Should Global Variables Be Recommended in Embedded Software?

Scan to FollowLearn Embedded Together, learn and grow together When it comes to global variables, the most common discussion is about reducing their usage or the various drawbacks associated with them. Today, we will discuss a different perspective. For embedded software, the use of global variables has many advantages. This article will explore the advantages … Read more

Various Uses of Return in C Language

Various Uses of Return in C Language

According to the understanding of beginners, the task of return is to return the corresponding parameter, which is further processed in the outer function. In fact, the usage of return is not limited to this. Returning parameter values from the called function This type of application is the most common, usually in a function with … Read more

Ten Tips for Programming the 51 Microcontroller!

Ten Tips for Programming the 51 Microcontroller!

Based on the experiences of many microcontroller programming experts online, today I will summarize 10 tips for programming the 51 microcontroller. 1. Do not define too many variables. The lower 128 bytes are the storage area for user-defined variables (by default), and while variables can also be placed in the upper 128 bytes, it is … Read more

Why Global Variables Are Commonly Used in C Language Development for Microcontrollers

Why Global Variables Are Commonly Used in C Language Development for Microcontrollers

Click the aboveblue text to follow us In C language development for microcontrollers, the use of global variables is indeed very common. This programming style is mainly due to several important reasons: 1 Performance and Resource Constraints In embedded systems, resources (such as memory and CPU time) are often very limited. Using global variables can … Read more

The Dominance of Global Variables in Microcontroller Development

The Dominance of Global Variables in Microcontroller Development

⚡ The Dominance of Global Variables in Microcontroller Development Global variables, often “disliked” in desktop application development, are widely used in the field of microcontrollers. This seemingly contradictory phenomenon hides the unique operating environment and development constraints of embedded systems. // Typical microcontroller program structure volatile uint8_t flag = 0; // Interrupt flag uint32_t system_ticks … Read more

The Importance of Modular Programming and Driver Separation in Embedded Systems

The Importance of Modular Programming and Driver Separation in Embedded Systems

Follow and star our official account, to access exciting content Source: zhzht19861011 Introduction When a project team undertakes a relatively complex engineering task, it means that you are no longer working alone. Instead, you collaborate with team members, each responsible for a part of the project. For example, you might only be responsible for the … Read more

Minimizing Global Variables in Embedded C Programming

Minimizing Global Variables in Embedded C Programming

This article discusses the issue of global variables in embedded C programming. In embedded systems, especially in OS-less microcontroller programs, a common mistake is the excessive use of global variables. This phenomenon is often seen among programmers transitioning from early assembly languages and beginners, who tend to use global variables almost like function parameters. They … Read more