A more effective microcontroller programming ideas

I used to work on a two-year MCU product and gradually formed a generally fixed overall framework during the programming of the MCU. It can also be said to be a programming idea. It is proposed for your reference.

First of all, to classify peripheral chips, the program that belongs to the same function or the same chip adopts a modular form, and is implemented by a fixed number of functions. Generally, the function functions between different chips do not overlap as much as possible, and do not use a function to cover several functions. The chip, in order to facilitate the later debugging, if it involves the communication between the chips, can be listed separately, using a special function for processing;

Secondly, the work to be done in the MCU is categorized according to priorities. In general, I will set two timer interrupts, one of which is roughly around 20mS. It is used to handle some button stabilization operations, time and date calculation, and after input processing. Some real-time requirements such as corresponding flag bits and device refresh are not very high, but there must be time required for transaction processing. In addition, a timer interrupt is set to be less than 1mS. It is mainly used to implement clock reference and to perform some real-time and highly demanding operations. Generally, high-priority real-time interrupts need to be set to high priority. Otherwise, normal operation cannot be achieved. If there are still serial interrupts to be processed, the code length in real-time interrupts needs to be strictly controlled to avoid delays in serial interrupts. Processing, there is also if the use of software to achieve serial and wireless communication soft decoding occasions, but also a reasonable allocation of the code length of each part;

Finally, the normal event detection and processing and response are implemented in the main program body. This part generally requires only a few parallel functions, and the main program body can be implemented with a few simple lines of code.

I used the above structure to develop a number of single-chip products, including wireless anti-theft alarm host containing wireless soft decoding, RS485 repeater (a drag 100), alarm receivers with Chinese display, etc., have achieved a stable and effective operation.

A more effective microcontroller programming ideas

I hope some of my personal experience will help everyone!


On/Off Grid Solar Inverter

Whaylan On/Off Grid Solar Inverter

Pure sine wave output
The electrical waveform output of PH1800 is pure sine wave, which has the same quality as practical power supply or household power supply. This waveform is suitable for most electrical equipment, appliances and tools. This pure sine wave unit provides more functions than an improved sine wave inverter because it has a cleaner form of power. Pure sine wave can also reduce the noise generated when applying electrical appliances to a limited extent.

Mppt Hybrid Solar Inverter

On/Off Grid Solar Inverter,Hybrid Inverter With Mppt Charge,pure sine wave solar inverter

suzhou whaylan new energy technology co., ltd , https://www.whaylan.com