Assignment Brief:
- Understanding formats: Browse through the data sheet for your microcontroller to interact (with local input &/or output devices)
- Compare the performance and development workflows for other architectures.
- Write a program microcontroller development board, to interact with local input &/or output devices and communicate with remote wired or wireless devices.
- Extra credit: use different languages &/or development environments
- Extra credit: connect external components to the board
Embedded Programming
Embedded programming is writing software that runs on specialized devices rather than general-purpose computers. These devices, like washing machines, smartwatches, or car engines, have tiny computers (microcontrollers or microprocessors) inside them that control how they work. Unlike regular software, embedded programs are designed to be efficient, reliable, and work with limited memory and power. They are written in languages like C or Python and directly interact with the hardware to perform specific tasks, like turning on a motor or reading sensor data.
Microcontrollers and microprocessors
Microcontrollers and microprocessors are both types of computing chips, but they serve different.
Microcontroller (MCU): A small, self-contained chip with a processor, memory (RAM & ROM), and input/output (I/O) ports all of this built into one unit is a microcontroller. It is designed for specific tasks in embedded systems, like controlling appliances, cars, or IoT devices. Since everything is integrated, it consumes less power and is cost-effective.
Microprocessor (MPU): A more powerful chip that mainly consists of a processor (CPU) without built-in
memory or I/O ports. It relies on external components to function, making it more suitable for complex
tasks like running an operating system on a computer or smartphone. It is faster and more flexible but
requires more power and additional components.
In-build Parts
Processor: You can think of the processor (CPU - Central Processing Unit) as the brain of a computer or device.
Memory (RAM & ROM):To learn more about Memory in microcontroller refer to
attatched
Link.
RAM (Random Access Memory) is a temporary memory that stores data while a device is running. It is fast
but loses all data when power is off.
ROM (Read-Only Memory) is a permanent memory that stores essential data, like the system’s startup
instructions (firmware). It retains data even when power is off.
Different Types of Memory in
Microcontroller
- PWM (Pulse Width Modulation) – Output Control: Used to control devices like motors, LEDs, and audio signals by varying pulse width. Helps adjust brightness (LEDs) or speed (motors) without needing extra power. Common in microcontrollers for efficient power management.
- Serial Communication (Modulated Signals) – Data Transfer:
Microprocessors use UART (Universal Asynchronous Receiver-Transmitter), I2C (Inter-Integrated
Circuit), SPI (Serial Peripheral Interface) - Serial
communications to exchange data with sensors, displays, and memory chips.
- UART (Universal Asynchronous Receiver-Transmitter) – Like texting on a phone. Uses TX (Transmit) to send and RX (Receive) to get messages. No clock signal (both sides must agree on the speed beforehand). Simple but not the fastest.
- I2C (Inter-Integrated Circuit) – Like a classroom discussion. Uses only 2 wires: SDA (Data Line) → Carries the message. SCL (Clock Line) → Keeps everyone in sync. Can connect many devices using the same 2 wires. Slower than SPI but saves wiring.
- SPI (Serial Peripheral Interface) – Like a private hotline. Uses 4 wires for communication: MOSI (Master Out, Slave In) → Sends data. MISO (Master In, Slave Out) → Receives data. SCLK (Clock) → Keeps timing in sync. CS (Chip Select) → Chooses which device to talk to. Fastest communication but needs more wires.
- What is a Clock?
Think of it like a conductor in an orchestra, making sure all devices send and receive data at the right time and simultaneously support the cycles. - I2C & SPI use a clock, while UART does not (which is why UART devices must agree on speed before talking).
- Multiple Wires? Some protocols (like I2C) use fewer wires to save space. Others (like SPI) use more wires for faster data transfer.
Serial Communication
I2C Communication
Serial Peripheral Interface
Group Assignment
Comparison of Toolchains and Development Workflows for ATmega and RP2040 ATmega (used in AVR microcontrollers) and RP2040 (used in Raspberry Pi Pico) are two popular embedded architectures. Below is a comparative demonstration of their toolchains and development workflows.
ATmega328 Toolchain
The ATmega328 is an 8-bit microcontroller commonly used in Arduino boards (like the Arduino Uno). To develop software for this microcontroller.
Editor (To write the code):
You can use Arduino IDE, PlatformIO, or a general editor like VS Code.
Programming is usually done in C or C++.
Compiler (To convert human-readable code into machine code)Compiler(To convert human-readable code into machine code)
The AVR-GCC (GNU Compiler Collection for AVR) is used to compile the code.AVR stands for Advanced Virtual RISC. It is developed by Atmel (now part of Microchip Technology). These microcontrollers are designed with a simple and efficient RISC (Reduced Instruction Set Computing) architecture, allowing them to execute commands quickly and consume less power.
Linker (To connect different parts of the program)
This arranges the compiled code properly for execution.Flasher/Programmer (To upload the code to the microcontroller):
The AVRDUDE (AVR Downloader/Uploader) is used to transfer the compiled code (.hex file) into the ATmega328 chip using an ISP (In-System Programmer) or USB-to-serial converter (like an Arduino bootloader).Debugger (To check and fix errors in the program)
The SimAVR simulator or hardware debuggers like Atmel ICE can be used for debugging.ATmega Development Workflow
🔹 Step 1: Setup Environment
- Install Arduino IDE or AVR toolchain (AVR-GCC, AVRDUDE)
- Choose programming method: USB (Arduino) or ISP (Bare ATmega328)
- Connect hardware (Arduino board or ATmega328 with ISP programmer)↓🔹 Step 2: Write Code
- Write program in C/C++ (Arduino IDE or raw AVR)
- Define pin configurations, logic, and functions↓🔹 Step 3: Compile Code
- If using Arduino IDE: Click Upload (compiles automatically)
- If using AVR-GCC: Compile manually to generate .hex file↓🔹 Step 4: Upload Code
- If using Arduino IDE: Upload via USB
- If using ISP Programmer: Use AVRDUDE to flash the .hex file↓🔹 Step 5: Debug & Test
- Use Serial Monitor (UART) for debugging
- Check outputs using LEDs or external debugging tools↓🔹 Step 6: Optimize & Finalize
- Optimize power consumption and memory usage
- Burn bootloader (if required)
- Lock fuses to prevent accidental overwriting↓END
Microcontroller Memory Classification:

Program memory includes different types of ROM:

(Second Image) Types of Program Memory in Microcontrollers. Program memory includes different types of ROM: ROM (Read-Only Memory) – Pre-programmed, non-modifiable. PROM (Programmable ROM) – Can be programmed once. EPROM (Erasable and Programmable ROM) – Erased using UV light and reprogrammed. EEPROM (Electrically Erasable and Programmable ROM) – Erased and rewritten electrically.
Relevance of EEPROM in Today's Microcontrollers: EEPROM is crucial in modern microcontrollers for storing non-volatile data, such as calibration settings, configuration data, and user preferences, without requiring an external storage device. Unlike Flash memory, EEPROM allows byte-wise erasing and writing, making it suitable for applications that require frequent updates without wearing out the entire memory block.
Input/output (I/O) ports: I/O refers to how a device interacts with the outside world. Input: Data or signals received by a device to process Output: Data or signals sent by a device after processing. Modulation is the process of altering a signal to transmit data efficiently. Modulation is the process of modifying a signal (message) so it can be efficiently transmitted over a medium, like radio waves or cables. In microprocessors, modulation plays a key role in controlling outputs and communicating with other devices.To learn more about Why Modulation is Required ? Types of Modulation Explained. refer to attatched Link.
Types of modulation in microcontrollers::

Data Transfer through Modulation:
