
Some engineers may feel that microcontrollers lack technical depth, but the reality is that microcontrollers encompass a vast array of technologies. From the low-level to applications, it is unlikely that anyone can master all the technologies involved.
From the perspective of interviews, let’s discuss the common questions asked for microcontroller engineer positions.
1. What could be the reasons for a microcontroller not running after power-up?
Possible reasons include power supply issues (such as VCC voltage deviating from the normal range), crystal oscillator problems (like a damaged or non-oscillating crystal), incorrect logic level on the RESET pin (such as being stuck in reset state), programming download or erase issues (like flash not being downloadable or damaged), and control program issues (such as bugs in the program).
2. What is the function of a watchdog timer?
The watchdog timer is used in embedded systems to monitor and reset the system to prevent crashes due to software failures. It periodically checks if the system is operating normally and triggers a system reset upon timeout, thereby enhancing the reliability and stability of the system.
3. What is the interrupt handling process in a microcontroller?
The interrupt handling process in a microcontroller typically includes three steps:interrupt response, interrupt handling, and interrupt return.
When an interrupt occurs, the interrupt system automatically generates a long call instruction (LACLL) through hardware, pushes the breakpoint address onto the stack for protection, and loads the corresponding interrupt entry address into the program counter (PC), redirecting the program to execute the interrupt service routine at that entry address. After the interrupt service routine completes, the computer uses the interrupt return instruction (RE) to pop the breakpoint address from the stack, return to the program counter (PC), and notify the interrupt system that the interrupt handling is complete.
4. Explain the concepts of process, thread, and coroutine.
Process:A process is the basic unit of resource allocation and management for concurrently executing programs, representing a dynamic concept and the fundamental unit competing for computer system resources.
Thread:A thread is an execution unit within a process, serving as a scheduling entity within the process. It is a smaller, independently running basic unit than a process, often referred to as a lightweight process.
Coroutine:A coroutine is an even lighter-weight entity than a thread. A single thread can have multiple coroutines. Its execution process is more akin to a subroutine or a function call without a return value.

5. What is an embedded system?
An embedded system is a dedicated computer system based on application, utilizing computer technology, with customizable hardware and software. It is suitable for applications that have strict requirements for functionality, reliability, cost, size, and power consumption. Embedded systems typically consist of processors, memory, input/output devices, and software, characterized by small size, low power consumption, high reliability, and specialized functions.
6. What is the difference between heap and stack in C language?
The heap and stack are two different areas used for data storage in C language. The stack is automatically allocated and managed by the system, typically used for storing local variables and temporary data during function calls; whereas the heap requires manual allocation and deallocation by the programmer, usually used for storing dynamically allocated data. They differ in terms of content storage, management methods, size, fragmentation potential, growth direction, allocation methods, and allocation efficiency.
7. Briefly describe the RTOS scheduling strategies in embedded systems.
The scheduling strategies of RTOS (Real-Time Operating System) include priority-based scheduling, round-robin scheduling, and time-slice scheduling. These strategies directly affect the real-time performance and efficiency of the system, ensuring that tasks are executed according to predetermined requirements.
8. How do you ensure the quality and reliability of microcontroller code?
In microcontroller projects, I typically take the following measures to ensure code quality and reliability: First, I conduct rigorous testing and validation of the code, including unit testing, integration testing, and system testing; second, I adhere to good programming standards and code style to improve code readability and maintainability; finally, I regularly review and update the code to eliminate potential errors and vulnerabilities.
9. Where do local variables, global variables, and dynamically allocated data reside in a program?
- Local variables reside in the stack area.
- Global variables reside in the static area (data segment).
- Dynamically allocated data resides in the heap area.
10. How do you implement a linked list in C language? Please provide an example.
A linked list is a dynamic data structure composed of nodes, where each node contains a data part and a pointer to the next node.
In C language, a linked list can be implemented using structures and pointers. For example, a node of a singly linked list can be defined as:
struct Node {int data;struct Node* next;};
Then, by dynamically allocating memory and setting pointers, a linked list can be constructed. For instance, creating a new node and inserting it at the beginning of the linked list:
struct Node* head = NULL;struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));newNode->data = 10;newNode->next = head;head = newNode;


Screenshots of some electronic books

Screenshots of some courseware PPTs

【Complete Set of Hardware Learning Materials】
