Shortcut to seniority
Home
Go to main page
Section level: Junior
A journey into the programming realm
Section level: Intermediate
The point of no return
Section level: Senior
Leaping into the unknown
Go to main page
A journey into the programming realm
The point of no return
Leaping into the unknown
Embedded programming, or microcontroller programming, refers to developing software for small computers.
The difference between embedded and full OS-based programming is that the developers need to take into account the limitations of the hardware.
All computers consist of components (CPU, memory, controllers, video) that are connected together through a bus.
A bus consists of wires that are usually printed on the main circuit board, and through this bus, data, clock and control signals are sent back and forth between components.
A particular bus follows a standard that describes what signals are carried on the wires, and what those signals mean.
The CPU continuously execute machine instructions, and these often involve accessing the main storage or using an I/O controller. Some machine operations are placed directly into the CPU (thus without involving the BUS), and these operations are extremely fast.
Input/output controller receives input and output requests from the CPU, and sends device-specific signals to the devices it controls.
Therefore, the CPU does not need to know specifically how each device can be controlled - that’s driver’s job.
The I/O controllers are part of the electronics on the motherboard, but could be that some devices require their own controller which must be plugged in into a connector on the motherboard.
When you install a new device on your computer (GPU for example) you also need to install a device driver for it. The device driver directly interacts with the I/O controller (device controller).
I/O controllers can process simple logic level inputs/outputs, such as changing the status of a power LED or detecting that a button was pressed.
They can be configured to indicate when events happen through special signaling called interrupts.
A System on a chip is a microchip that contains all the necessary electronic circuits and parts for a given system, directly on a single integrated circuit, such as a smartphone, for example.
A smartphone contains the CPU, the GPU, the RAM memory, the main memory, and a modem to connect to radio networks (for networks / cellular connectivity).
A bus consist of wires that are usually printed on the main circuit board, and through this bus, data, clock and control signals are sent back and forth between components.
Examples of a data bus include:
Arduino
Arduino boards are able to read input (messages, button presses, etc.) and turn them into output (turning LEDs on/off, performing some action). You can tell it how to act by sending a set of instructions to the microcontroller on the board.
Raspberry PI
Raspberry PI is a low cast small computer, that plugs into a monitor or TV, and uses standard peripherals such as keyboard and mouse.
It is capable of doing anything a computer could do, such as browsing the web or playing videos.
Embedded devices may contain sensors to determine its position or orientation, such as the gyroscope and the accelerometer.
Accelerometer measures the acceleration force (the change in velocity) of an object, thus determining its movements. Accelerometers are designed to respond to vibrations associated with movement, by using microscopic crystals that go under stress when vibrations occur, and from that stress, a voltage is generated to create a reading on any acceleration.
Acceleration is the measurement of the change in velocity.
If a car accelerates from 0 to 100km/h in 10 seconds, it has an acceleration of 10km per second.
Examples of accelerometer usages:
A gyroscope is an instrument that measures the orientation of a device, by using the Earth’s gravity.
It is designed as a freely-rotating disk (a rotor), mounted on a spinning axis in the center of a stable wheel. As the axis turns, the rotor remains stationary, indicating the central gravitational pull (showing which way is ‘down’).
This is the base of any embedded programming, mainly because it is the fastest and most energy efficient language, and because it can directly access the hardware of a device.
You may need to know how to write drivers for a piece of hardware, and you will definitelly need to know some shell commands to interact with the device.
Interrupts: Interrupts are events that alter the sequence in which the CPU executes the instructions.
Assembly: You may also need to know how to read assembly code.
Analog to digital converter (ADC): used to convert analog values from real world into digital values (0/1).
Digital to analog converter (DAC): used to convert digital values into analog signal.
Pulse Width modulation (PWM): used to generate an analog signal using a digital source.
Direct memory access: used to allow an I/O device to send or receive data directly to or from the main memory, independent of the CPU.
There are different communication protocols used to connect devices together, in order to transmit and receive data.
Examples of basic communication protocols:
Examples of advanced protocols:
You may need to know how to read a schematic of an electronic, to understand what connects where, and to know how to use the available sensors.
Artifacts are anomalies that are present during the visual representation of a graphical object. Can appear due to software bugs, overclocking the video card, driver-related issues, temperature of the hardware, etc.
Null object pattern/idiom is used when working with pointers. Instead of setting the pointer to null and verifying if it’s null, or doing a null pointer dereference by mistake, we provide a default implementation that does nothing when functions are called.