Introduction to Embedded Systems — Microchips and Microcontrollers

Rick
4 min readFeb 10, 2023

--

picture by federicoag

Tips and tricks

  • take into consideration that wireless comms consume a lot of energy
  • video data does that as well. (from my class of intro to computer networks, we also know wireless communications are very susceptible to noise)
  • Practice your flow charts because it can make a complex project simpler to understand.

Must knows

Uses for a Field Programmable Gate Arrays (FPGAs)

  • It’s a reprogrammable digital device
  • Fundamentally, It’s architecture is sequential ; some instructions depend on the previous output of a previous instruction [1] [2]
  • Also, it’s used to prototype and design digital systems
  • You could try to design a simple MIPS processor to get comfortable with VHDL.

Microcontroller vs Microprocessor

  • A Microcontroller has peripherals, in other words, depending on what chip it is, you could have sensors connected to this microcontroller and decide what to do with your data (note not all microcontrollers have A/D or D/A converters).
  • A Microprocessor doesn‘t have peripherals, think of it as an actual CPU. It has a set of instructions and process the instructions as the user defines or creates the program

Thought experiment

Say for example that you are learning sign language. If you don’t know a word and you’re trying to communicate with someone who already knows sign language, you could fingerspell and ask for the exact sign for that word. Why am I bringing this up? Not knowing a word takes more time to communicate. In the same way, having a reduced set of instructions for a microcontroller can be very limiting when we want to accomplish a task. Writing more Instructions could result in a task being resolved in more clock cycles than needed.

Basic Architecture of a microchip

  • In the labs we are going to use the ATmega328p which is a microcontroller from the family of the 8 bit AVR architecture.
  • In a microcontroller we usually have a CPU, memory, I/O ports, oscillators, timers, Comms Interface, Analog circuits(most of the time) and programmable logic (this is the part we’re most interested in).
  • The memory part is referred as the RAM, EEPROM, flash (program memory)
  • Digital to analog converters(DAC) and Analog to digital converters (ADC) are usually built in microcontrollers but it’s not impossible for microcontrollers to not have them. Naturally, this part helps the chip communicate and process the analog signals from the real world. for more info you can check this article [3]. (this webpage is in spanish but you can still gather info from the images)

Steps to design a solution for a task

  • A microprocessor only understands 0s and 1s, so it’s wise to have a plan or a number of steps to follow in order to go from an idea to machine language.
  1. Flow chart: Understanding the requirements for your task is important so you can have a clear idea of what you need to do. Make a flow chart indicating every step of the logic of your program. An easy tool to make flow charts is LucidChart.com if you’re in need of one.
  2. C++ code: after you’ve laid out the steps and understood the logic of your task, you can start by making a C/C++ code that simulates the results that you have in mind
  3. Assembler: after you have your C/C++ code you can actually translate the code to assembler code.(this step is optional, this was for my class)
  4. Linker: this part isn’t necessarily done by the user but the linkers job is to take the machine code that is created from the assembler code and produce a file which will go to the FLASH memory of the microcontroller (note that this memory is non-volatile, the program will remain in the memory as long as the user decides to)

Arithmetic Logic Unit (ALU)

  • you may have some idea of what an ALU is and what it’s used for. Making arithmetic and logic operations but how?
Figure 1.the ALU

By experience one would say you enter two operands and an Opcode and out comes the expected value. But there’s more to it than just that. Down below there ́s an image the datapath of a simple MIPS processor, note that there is an ALU as one the main components

Figure 2. Schematic of the Datapath of a MIPS processor [3]

This is an actual computer processor which was widely used back in the day. The playstation 2 had a MIPS processor, the 300 MHz MIPS «Emotion Engine» (not quite the one from the image above). So in a sense an ALU isn’t a trivial digital component. But how does a digital circuit that only understands 0s and 1s know how to do stuff? First the assembler code is transformed to machine code in Hexadecimal Hexadecimal is converted to binary The trick is that the right bits are directed to the right place via data buses from there it enters multiplexers and memories and control circuits. These concepts may become a bit more intuitive if you try to build your own MIPS processor.(note that it’s important to know basic digital circuits theory

If these concepts about computers and processors are still confusing check out the book Computer Organization and Design by David A. Patterson and John L. Hennessy

References

1. Krishna, Gopal & Roy, Sahadev. (2017). Fundamentals of FPGA Architecture. Availble at: https://www.researchgate.net/publication/321024930_Fundamentals_of_FPGA_Architecture/citations

2. Ni.com. 2020. FPGA Fundamentals. [online] Available at: https://www.ni.com/en-us/innovations/white-papers/08/fpgafundamentals.html> [Accessed 15 September 2020].

3. Schmalz, M., n.d. Organization Of Computer Systems: Processor & Datapath. [online] Cise.ufl.edu. Available at: https://www.cise.ufl.edu/~mssz/CompOrg/CDA-proc.html> [Accessed 15 September 2020].

--

--

Rick
Rick

Written by Rick

I blog about everything I learn, Digital Image Processing, Data Science, IoT, Videogame design and much more :)

No responses yet