Week 4: Embedded Programming

Group Assignment Requirements

  1. Demonstrate and compare the toolchains and development workflows for available embedded architectures.
  2. Document work to the group work page and reflect on your individual page what you learned.
During this week we started by learning about the electronic basic concepts, primarly focusing on microprocessers and microcontrollers.

Microcontroller vs Microprocessor

Microprocessor vs microcontroller
  1. Integration and Components: Microcontrollers combine all the essential elements of a microcomputer—the CPU, memory (RAM and ROM), and input/output (I/O) peripherals—onto a single piece of hardware. Conversely, microprocessors consist solely of a CPU and require external memory and specialized hardware to function properly.
  2. Architecture: Most microcontrollers use the Harvard architecture, which features a dedicated set of buses for data and another set for instructions. Because it can fetch instructions and read data memory at the same time, this architecture excels at real-time and high-speed basic operations. Microprocessors typically use the classical von Neumann architecture, which uses the same bus to transmit both data and instructions. Though this can create a bottleneck, the unified memory space results in improved reliability and scalability for more demanding computing tasks.
Architecture comparison visual
  1. Power and Cost: Microcontrollers are small, highly cost-effective, and have low power consumption, making them perfect for battery-operated devices. Microprocessors, on the other hand, boast high-power processing but come with much higher power consumption and a higher price tag.
  2. Use Cases: Because they are optimized for specific standalone functions, microcontrollers are used in embedded systems, Internet-of-Things (IoT) devices, automotive infotainment systems, and wearables like smartwatches. General-purpose microprocessors are much more powerful and are designed for demanding, complex applications like personal computing, servers, gaming, and industrial supercomputers.

Here is a good reference to know more about the differences between microcontrollers and microprocessors.


In this week assignment we have only deal with microcontrollers and their toolchains.

1. Architecture Comparison

Feature ESP32‑C3 ESP8266 ATtiny48 XIAO RP2040 Arduino Uno
Core / Arch. RISC‑V 32‑bit Tensilica L106 32‑bit AVR 8‑bit Dual ARM Cortex‑M0+ 32‑bit AVR 8‑bit
Max Clock 160 MHz 80/160 MHz 12 MHz 133 MHz 16 MHz
Flash 4 MB 4 MB typical 4 KB 2 MB 32 KB
SRAM 400 KB 160 KB 256 B 264 KB 2 KB
Digital I/O ~22 16 24 26 14
Analog Inputs 6+ 1 6–8 3 6
PWM Yes Yes Yes Yes Yes
Voltage 3.3 V 3.3 V 1.8–5.5 V 3.3 V 5 V
Connectivity Wi‑Fi / BLE Wi‑Fi I²C / SPI USB / UART / SPI / I²C UART / SPI / I²C
Our Instructor Naim Haj-Ali explained the key concepts of:
  1. Differentiating Microprocesser from a microcontroller
  2. Soldering Techinques
  3. Arduino IDE interface
  4. Datasheet exploration
  5. Debugging and Troubleshooting examples

Important Abbreviations and Definitions

Abbreviation Meaning
MHzMegahertz – CPU clock speed (millions of cycles per second).
KB / MBKilobyte / Megabyte – memory size (1 KB = 1024 bytes).
SRAMStatic Random-Access Memory – fast, volatile memory used for program execution.
PWMPulse Width Modulation – method to simulate analog output using digital signals.
GPIOGeneral Purpose Input/Output – pins that can be programmed as input or output.

Connectivity Definitions


2. Toolchains Introduction

A toolchain is the collection of software tools used to compile, build, and upload firmware to an embedded system such as:


3. Test

A speed test to compare RP2040 vs ESP32 vs Arduino Uno

We did a speed test to compare the performance of the RP2040, ESP32, and Arduino Uno microcontrollers. The test involved running a program that figured out the binary numbers from 0 to 5000 and measured the time taken by each microcontroller to complete the task. The results showed that the RP2040 was the fastest, followed by the ESP32, and then the Arduino Uno.

void setup() {
  Serial.begin(115200);
  while (!Serial); // Wait for Serial to open

  delay(2000);
  Serial.println("--- Speed Test Start ---");

  long startTime = micros();

  // Benchmark: Find primes up to 5000
  int count = 0;
  for (int i = 2; i < 5000; i++) {
    bool isPrime = true;
    for (int j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime) count++;
  }

  long endTime = micros();

  Serial.print("Primes found: ");
  Serial.println(count);
  Serial.print("Time taken (us): ");
  Serial.println(endTime - startTime);
  Serial.println("--- Test Complete ---");
}

void loop() {}

Here are the results we got from the test:

Microcontroller Time Taken (µs)
Arduino Uno1148340
ESP32-c3374423
RP2040-
If you want to run this test on your own microcontroller make sure to:
  1. Select the correct board and port in the Arduino IDE before uploading the code.
  2. Open the Serial Monitor and make sure to choose the correct baud rate (115200 baud) to view the output results.