Microcontroller vs Microprocessor
Microprocessor: Just the CPU.
Microcontroller: CPU + Memory + Peripherals.
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide15.png
What can we use I/O ports for? Let’s say an 4 8-bit ports
For sensors and multiplexing
What does
RAM, ROM, GPIO, UART, SPI, I2C, ADC, DAC
stand for
-RAM: Random Access Memory
- ROM: Read-Only Memory
- Flash: Flash Memory (a type of EEPROM)
- GPIO: General-Purpose Input/Output
- UART: Universal Asynchronous Receiver/Transmitter
- SPI: Serial Peripheral Interface
- I2C: Inter-Integrated Circuit
- ADC: Analog-to-Digital Converter
- DAC: Digital-to-Analog Converter:
The Vertically Integrated (Proprietary) Model
A single company controls the entire stack: CPU design, peripheral integration, chip manufacturing, and sales. This creates a self-contained ecosystem with proprietary tools and architectures
Examples: Microchip PIC and Atmel AVR
The ARM Ecosystem (IP Licensing)
ARM designs processor cores and licenses them to other companies. These companies then build unique microcontrollers around the licensed core.
The Programming Hierarchy
Modeling languages
Customer > Object-oriented languages > Procedural languages > Assembler languages > Machine code
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide19.png
What is an Embedded System?
An embedded system is a specialized computer system; a combination of a processor, memory, and input/output peripherals that has a dedicated function within a larger mechanical or electrical system.
SIMPLE EMBEDDED SYSTEM
Describe:
- Primary goal
- Examples
- Software stack
- User interaction
- Resources
Define “Firmware”
A Hardware-Specific, Single Application computer software that provides low-level control for a device’s specific hardware. Its a permanent program, often stored in non-volatile memory (Flash, ROM, EEPROM).
Volatile and nonvolatile memory examples
Volatile: DRAM, SRAM. They lose data when powered off.
Non-volatile. Retains data without power
- ROM (Read-Only Memory) – Permanent, non-modifiable.
- Flash– Rewritable
- EEPROM– Electrically erasable
Microprocessors
A single chip containing the full central processing unit (CPU). It’s a clock-driven programmable device (determined by software) that processes binary data using ultra-fast storage (registers).
They are the communication pathways in a computer system.
Buses
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide4.png
Bus that specifies the memory location to access.
Address Bus
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide4.png
Bus that carries data between the CPU and memory.
Data Bus
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide4.png
Bus that transmits control signals.
Control Bus
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide4.png
A mechanism for hardware or software to request the CPU’s attention. It allows for efficient handling of asynchronous events.
Interrupts. The CPU suspends its current task, services the interrupt, and then resumes.
https://sem2.rezafara.com/Microcontroller_1/week1/images/slide9.png
Multiplexer operation and mayor disadvantage
A multiplexer acts as a switching circuit that selects one of several inputs to send to the single output.
One major disadvantage of multiplexers is that instead of sampling each input value every frame, inputs to multiplexers must wait their turn to be sampled from the single input pin. Data may be lost during frames where the input is waiting to be read.
Why Use Assembly?
Direct Hardware Control: To manipulate specific hardware registers that are not accessible from C.
Performance Optimization: Hand-crafting assembly for critical loops can be smaller and faster than compiler-generated code.
Bootloaders & Startup Code: The very first code a processor runs after power-on is often in assembly to set up the system before C code can run
Core Components of a Microprocessor
Arithmetic Logic Unit (ALU)
Control Unit
Registers
Arithmetic Logic Unit (ALU)
Performs arithmetic operations (addition, subtraction) and logical operations (AND, OR, NOT).
Control Unit
Directs the flow of operations. It fetches instructions from memory, decodes them, and generates control signals to execute them.
Types of Registers
General-Purpose Registers: Used to store data temporarily during program execution.
Special-Purpose Registers:
- Program Counter (PC): Holds the memory address of the next instruction to be executed.
- Instruction Register (IR): Holds the current instruction being executed.
- Accumulator: A primary register for storing the results of ALU operations.
- Status Register (or Flag Register): Contains flags that indicate the status of the processor and the results of operations (e.g., zero flag, carry flag, overflow flag).
The Fetch-Decode-Execute Cycle
This is the fundamental process of a microprocessor
Fetch: The control unit fetches the next instruction from the memory location pointed to by the Program Counter (PC) and stores it in the instruction register.
Decode: The instruction it is decoded by the control unit to determine what operation is to be performed.
Execute: The control unit sends signals to the appropriate parts of the microprocessor (like the ALU) to perform the operation. The PC is then updated to point to the next instruction, and the cycle repeats.
How are CPU, memory, and I/O devices connected?
By the address, data, and control buses.