Summary of MSP430 microcontroller programming ideas (1)

1. In the main function main(); only call the initialization function and execute the background program;
2. Do not write "substantial" code in the interrupt service subroutine function. Only call the event detection function to improve the readability of the program
3. WDT can be used as a beat timer in MCU programming, which is of great significance; the timing scan polling method can solve a large number of CPU blocking problems
4. The event function is very important to understand the program intent; It is very efficient to focus on "event detection/processing" instead of following the "chaotic" interrupts all over the world to find event functions.
5. The use of global variables should be very cautious. Global variables are often the link between key functions. Therefore, placing global variables centrally is also a common practice to increase program readability.
6. In addition to reading and writing registers (including rewriting IO output), mathematical and logical operations, CPU doing other things such as long delay, infinite loop type of query is the behavior of blocking the CPU, should be resolutely avoided
7. When the CPU determines that there is no task When it needs to be executed, hibernation is the best choice. Correct use of various levels of hibernation (wake-up) can greatly reduce the power consumption of the microcontroller;
8. The event class function is named "xxx_Event"; the global variable "xxx_Global" single-column file is very useful necessary

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325294482&siteId=291194637