Surely, each of us heard about programmable devices (chips), for example, on the Arduino platform. They can be programmed in some programming languages, for example, in C.

The question is: how can the same C compiler be able to compile the C code into exactly the kind of Assembler that supports the device. Is this a special compiler designed specifically for this type of device that is not supported on regular PCs? Or does the C-compiler compile the code directly into an "one and zero" array?

The main question is: if, say, a person at home solders a certain device from scratch, how will he program it? How in his device to push the same Assembler, or even cooler: C?

  • Shouldn't this device have a processor? I did not do this myself, but if on C, then some execute file should compile and be stored in the device’s memory. - Smash
  • Yes, of course, the device has at least one integrated circuit that operates with electrical impulses and a memory in which something can be put. - AseN
  • 2
    How does gcc make code (and usually use it)? but very simple. Since there is some kind of processor, it should have a system of commands. And since it is there and the compiler knows it (the programmer himself points out the platform), then you can generate code. Approximately, the compiler first creates the code in some general assembler, and then converts it to the specified one. - KoVadim
  • one
    absolutely any - of course not. But if there is a processor, then everything can be. - KoVadim
  • 3
    compiler generates binary code. This code is written to the ROM (ROM - read-only memory) or PROM (reflash). Roughly speaking - just a flash drive. The processor, when started, accesses it and starts reading the data at a specific address (this is all specific for each processor) and performs slowly. - KoVadim

1 answer 1

Start over:

  1. The device (Arduino) in question works on AVR microcontrollers (most often Mega families, which differ from each other in the number of input / output ports, ADCs (sometimes DACs, but very rarely, in my opinion, starting from By the way, there are also ready-made Arduino boards)). The program under arduino is written in C, most often, but there are compilers Basic, Pascal, etc.
  2. Immediately you need to understand that for each family of microcontrollers there is a separate compiler. For example, for AVR it is: AVR GCC (as the name implies, absolutely free), it is also included in the free package supplied by AVR developer AVR-Studio. At the initial stage, I would advise CodeVisionAVR, since it allows you to generate the initial C code, and this is a lot of time saved when working with the MC, because otherwise you will have to dig datasheets and deal with registers, communication interfaces, signal processing systems, etc. Allows you to immediately set the required processor clock frequency and activate standard timers-counters. There are also BascomAVR, MicroBasic, MicroC, MicroPascal, etc. But IAR embedded workbench should be especially noted. If there are installed libraries, it is possible to develop software on the kernel sub-microcontrollers: AVR, PIC, PIC32, MSP430, STM32 and ARM (the core on which all Ay and And devices are located) to write, of course, in C (pure C, no object-oriented programming and other hoaxes).
  3. Now how does it compile: when developing software in any of these packages, you install the kernel of the MK, its family, and a specific model, depending on this, the Asm file is first created, from which the compiler already makes .hex (plus for use in ISIS Proteus emulators).
  4. Now the main question is how to cram the resulting .hex file into the MK. a) You must purchase a programmer (for AVR, I would recommend Argussoft AS4) b) Your board must have a programming connector (the interface is most often ISP (SPI) or JTAG). c) install drivers on the PC from this programmer and through its standard software you drop your .hex file on the MK. PS On Arduino programmer is not needed, because He has his own bootloader and USB cable!
  • Well, thanks! But you are considering programming devices on the basis of existing, not self-made ones. - AseN
  • 3
    What does "existing devices" mean? And another note: the microcontroller is not a processor. It’s impossible to make the MK itself because it is impossible, another question is what is the FPGA MK that can be programmed so that it changes its structure. If you are talking about a programmer, then many of those that are on sale can be assembled by yourself. To do this, look for example: habrahabr.ru/post/128939 - vanyamelikov
  • By the way, for lovers of Eclipse, there is the possibility of writing programs for the MK in it: cxemotexnika.org/2010/06/… If you want to study the programming of the MK in more detail, download ISIS Proteus and collect diagrams in it, drop the program with one click and debug! - vanyamelikov