microcontroller
20
Feb
2024

What you need to program a microcontroller

In order for the microcontroller to be able to perform the necessary functions and solve certain tasks, it must be programmed.

The programming path goes through several steps:

Before you can start writing program code, you must decide on the end goal.
An algorithm for the operation of the program is drawn up.
The actual writing of the program code. The codes are written in C or Assembler.
Compiling the program, i.e. converting it into binary or hexadecimal 1 and 0. This is the only way for the computer to understand it.
The compiled code is written into the memory of the controller.
The firmware is programmed into the Microcontroller. There are two types of connection: via COM or USB. The easiest and cheapest is the USBASP programmer.
The testing and debugging of MC’s on a real device.

Radio amateurs sometimes do without prescribing the algorithm of the program on paper. They keep it in their head.

Programming Languages
Programming languages for MCs do not differ much from classic computer languages. The main difference is that MCs focus on working with peripherals. The architecture of the MC requires bit-oriented instructions. That’s why special languages were created for controllers:

Assembler. The lowest level of the language. Programs written in it are very long and difficult to understand. But nevertheless it is the best way to show the full power of the controllers and get the best performance and compact code. It is mostly suitable for small 8-bit MCUs.
C/C++. Higher level language. A program written in it is more understandable for a human. Nowadays there are a lot of program means and libraries allowing writing code in this language. Its compilers can be found on almost any model of MCU. For today it is the main language for programming controllers.
It is even easier to understand and design. But it is not used much for MC programming.

It is an old programming language. Nowadays it is almost not used.
The choice of programming language depends on the tasks to be solved and the required code quality. If you need a compact code, the Assembler will do, for the solution of more global problems the choice will be limited only to C / C + +.