Skip to content

Basic microcontroller concepts

Content aligned with Topic 1 — Basic concepts from the Microcontrollers course (UNEXPO · Mechatronics), based on Prof. Ing. Yoel Pire’s material.

A microcontroller (μC) is a programmable integrated circuit that puts the basic blocks of a tiny computer on one chip:

  • CPU — executes program instructions step by step.
  • Memories — store the program and working data.
  • Input/output lines — connect the chip to LEDs, buttons, sensors, etc.
  • Peripherals — internal or external modules that extend what the device can do.

To use it you write firmware: the CPU reads instructions stored in memory and runs them. There is no operating system like on a PC; control is direct.

Before the PIC, Topic 1 studies the general microcontroller scheme. The CPU has general-purpose registers (variables) and six special registers. Those six are the ones the professor names. The PIC18, later, gives them other names.

Special registerWhat it is
IR — instruction registerHolds the instruction the CPU is executing. The programmer does not see it. On the PIC18 it stays internal: you do not write it in the .ASM.
ACC — accumulatorThe ALU result lands here, under the ALU. That same value can go back in as an operand. The PIC18 has no classic accumulator. The close match is W (WREG), and it sits before the ALU.
Status registerResult flags: zero, carry, sign. On the PIC18 it is STATUS.
PC — program counterAddress of the next instruction. It advances on its own, unless there is a jump. On the PIC18 it keeps the same name: PC.
Data-address registerAddress of a data byte. Used for indirect addressing. It is not the memory. On the PIC18 it is FSR (the byte is read with INDF).
SP — stack pointerMarks the top of the stack. The stack stores addresses, not variables. On the PIC18 it is STKPTR. Older PIC texts say there is no visible SP; the PIC18 does have this one.
General scheme: the PC addresses program memory and the instruction enters the IR; the ALU leaves the result in the accumulator and the flags in the status register; the data-address register addresses data memory and the stack pointer marks the stack
Path of a traditional microcontroller. The PC sends the address and the instruction enters the IR; operation F leaves the IR toward the ALU. The result falls into the accumulator and the flags leave through D. The data-address register carries only an address. CALL saves the PC on the stack and RETURN brings it back. — Topic 1 general scheme

An orange box is a register. A gray box is the place that register points to.

The SP is the orange box: it holds one number, the address of the top. The stack is the gray box: the storage where the PC addresses sit. The arrow labeled “top” runs from that register to the upper slot. CALL stores the PC address there. RETURN takes the one on top and loads it back into the PC.

The data-address register works the same way. The orange register carries the address of the byte. Gray data memory is where the byte sits.

The ALU does the arithmetic: add, subtract, AND, OR, and the comparisons. The Topic 1 symbol is this V.

ALU symbol: A and B enter from the top, F from the left, R leaves at the bottom, and D leaves at the right
A and B are the values that enter. F selects the operation. R is the result. D is the flags, and they go to the status register. — Topic 1 symbol
LetterWhat it is
A and BThe two operands that enter
FThe kind of operation. The IR selects it
RThe result. In the general scheme it lands in the accumulator
DThe status of that result: zero, carry, sign. It goes to the status register

Code-level detail is in Architecture.

The stack is LIFO (Last In, First Out): the last item in is the first one out. The SP does not store those addresses: it marks which one is on top. The stack is what stores them.

  • PUSH stores an address (usually the PC, so the CPU knows where to return).
  • POP removes that address and loads it back into the PC.

A subroutine call PUSHes “where we were”. When it finishes, POP restores the PC. Without that pair there is no way back.

Microcontroller (μC)Microprocessor (μP)
What it integratesCPU, memory, buses, and peripherals in one chipOnly the CPU (processor)
System typeClosed — complete computer with fixed capabilityOpen — you attach external memory, I/O, and peripherals
External pinsLines that drive peripherals and portsAddress, data, and control buses to build a PC
ProgrammingYou focus on the applicationYou must also manage external devices
Academic examplePIC18F4550 (single chip)Classic PC CPU in a socket (RAM, chipset, and storage live on the motherboard, not inside the processor chip)
Comparison of architectures and embedded computing systems
The μC integrates CPU, memory, and peripherals in one chip; the μP is only the processor and the rest of the system is built separately. — Based on Topic 1 — Basic concepts · UNEXPO

Raspberry Pi and similar boards: not the same thing

Section titled “Raspberry Pi and similar boards: not the same thing”

A Raspberry Pi is not a microcontroller or a bare microprocessor. It is a single-board computer (SBC) — a mini PC already assembled on the board:

  • An SoC (System-on-Chip): application ARM cores, GPU, and other blocks in one integrated circuit.
  • RAM included on the board (soldered or in the SoC package, depending on model).
  • USB, HDMI, network, power, and GPIO connectors.
  • microSD (or internal storage) for the operating system and your programs.

You do not start from an empty chip and add RAM like in an academic μP-only design: the board is already a complete computer. It runs Linux (a full OS), not direct firmware burned to Flash like on the PIC.

PIC18F4550Raspberry Pi
What it isMicrocontroller (μC)Single-board computer (SBC)
ProgramFirmware in chip FlashOS + apps on SD card / Linux
MemoryFlash, RAM, and EEPROM inside the chipRAM on the board + storage on SD
Study levelRegisters, bits, assemblyPython, Linux, high-level drivers

Peripherals let the μC interact with the world. They can be inside the chip or wired outside.

Modules the manufacturer builds into the microcontroller. On the PIC18F4550 you will find, among others:

  • Timers / counters (Timer0, Timer1, Timer2)
  • A/D converter (ADC)
  • UART / USART (serial communication)
  • PWM / CCP module
  • SPI and I2C interfaces
  • USB (on the 4550)
  • Internal EEPROM memory

Devices not inside the chip, connected to pins:

  • Sensors (temperature, pressure, distance…)
  • Communication modules (Bluetooth, Wi-Fi, GPS…)
  • External memories
  • LCD or OLED displays
  • 7-segment displays
  • Matrix keyboards
  • Motors, relays, drivers

In the lab you use both: the PIC’s internal ADC and, for example, an external LCD wired to GPIO ports.

By how firmware is stored, the course distinguishes:

TypeWhat it isReprogrammable
ROMProgram burned at the factoryNo
OTPOne-Time Programmable — written onceNo
EPROMElectrically programmed; erased with UV lightYes (UV erase)
EEPROMElectrically programmed and erasedYes
FlashElectrically programmed; PIC18F4550 stores your .hex hereYes

On the PIC18F4550 the program lives in Flash (non-volatile: kept when power is off). Data you want to keep between power cycles can go in internal EEPROM.

TypeRole in the μC
RAMTemporary variables, counters, flags while the program runs. Lost on power-off unless saved elsewhere.
Special registers (SFR)Control ports, timers, ADC, etc. (covered in Foundations).

A microcontroller can be used in:

  • Sensor and actuator control
  • Industrial process control
  • Medical equipment and robotics
  • Appliances and human-machine interfaces (keyboard, display)
  • Motor control (PWM)
  • Communication (SPI, I2C, UART, USB)
  • Clocks, alarms, calculators, and many more

You now know the general Topic 1 concepts. Continue with What is the PIC18F4550 to see how these blocks apply to the chip you will use in the lab.

Interactive exam

Basic microcontroller concepts

Based on: Tema 1. Conceptos Básicos (1).pdf

0 of 0 answered

The fundamental blocks of a microcontroller are...
A microcontroller is a... system
On the PIC18F4550, the program (.hex) is stored in...
Which is an INTERNAL microcontroller peripheral?
PIC Flash memory is characterized by...
The instruction register (IR) holds...
The data-address register is...
A LIFO stack and a peripheral mean...