Q3 Embedded systems – 5 concepts

An embedded system is essentially a computer system – a combination of a processor unit, memory, IO peripherals – that has a specific function integrated into a larger mechanical or electronic system.

Since they do not require as much processing power as computers, these systems have very limited resources, which must be used carefully and wisely.

5 concepts of embedded systems:

1) General purpose IO devices

It can be represented by the ways for the microcontroller to communicate with the outside world, like the IO ports on a home computer, but much simpler.

The values that are loaded at the input and printed at the output are actually 1 and 0, which represent the voltage value of the microcontroller. 1 – represents 3.3 volts and 0 represents zero volts. These values are read through registers.

Registers are a type of computer memory that are used because of their high speed to accept, store, and forward data and instructions that the CPU can immediately load and use.

There are many applications in the world around us, one example is the switching on and off of LEDs, i.e. signaling to another system that the process passed without errors or that there were some errors.

2) Interrupts

Interrupts are useful in embedded systems when something needs to be done immediately after a certain event, e.g. when a block of code should be executed immediately after an event, unlike pooling when you have to wait inside a loop until a condition is met, or until some flag is set.

With interrupts, the only thing that needs to be done is to create an interrupt handler, which is essentially a simple function that is called as soon as an event occurs, and the code related to that event can be placed there.

This does not waste the cycles of the processor waiting for the event to occur, but rather sets the event on which the interrupt will be activated.

3) Timers

Timers can create timeouts (a specified period of time that should elapse before an event occurs), also, timers can count how long a process lasts, or they can even create a real-time clock.

The timer usually counts up, up/down and down.

When the timer is said to count up, it means that some value is set in the register and the timer counts up to the selected value, when it reaches it, it starts again from zero.

When a timer is said to count up/down, it means that a value is set in a register, the timer counts up to the chosen value, when it reaches it, then counts down all the way to zero, and then all over again.

The maximum value that is set in the register depends on the number of bits that the register has available, for example if the register has 3 bits, each bit can fit either 0 or 1, so we have 2 digits that can fit in 3 places, which gives 8 combinations, and since number systems start from zero, the maximum possible value in this example is 7 = 23-1.

4) ADC – Analog to digital converter

Allows operation with analog inputs. For example, if there is a voltage that needs to be measured, an analog to digital converter is used to get a number that can be used in software.

The picture shows a sinus function that represents the voltage, which is between the limits Vmax and Vmin, which depend on the bits we have. If we have 3 bits, Vmin will be approximately 0 and Vmax will be 7 (23-1). These limits must not be exceeded.

Given that the analog to digital converter outputs only integer values, the picture also shows a step function that follows the sinusoid, which further implies that there is a possible error between the value at the input and the value at the output.

There is also a digital to analog converter (DAC), but very few microcontrollers use it.

5) Serial Interface

It allows the transmission of data to other parts of the system or to other systems, thereby essentially enabling communication between devices.

UART (Universal Asynchronous Receiver Transmitter) requires only two data lines. It is used for communication of 2 devices, no more than that.

It signals the start of communication through the start bit, then there are 8 bits in which the data is placed, after that there is an optional parity bit to check if there were errors in the transmission and after it there is a stop bit that indicates the end.

SPI i I2C serial interfaces allow more than 2 devices to be attached to the same bus (data path) and thus allow higher data transfer rates.