Posts

Showing posts with the label fundamentals

How a CPU Executes Instructions

Image
Instruction Cycle and Pipelining Explained: Every program you write in C, C++, or assembly eventually becomes a sequence of machine instructions stored in memory. But how does a CPU actually execute those instructions? Inside every processor—from small microcontrollers to powerful server CPUs—the execution of a program happens through a repetitive process known as the Instruction Cycle. Understanding this cycle is one of the most fundamental concepts in computer architecture and embedded systems. What Is the Instruction Cycle? The instruction cycle is the sequence of steps the CPU follows to fetch, understand, and execute an instruction from memory. A CPU does not execute an entire program at once. Instead, it executes one instruction at a time, repeating the same internal process continuously. The classic instruction cycle consists of four stages: Fetch → Decode → Execute → Write Back After completing one instruction, the CPU immediately begins the cycle again for the next...

What Happens Inside a Microcontroller in the First Few Microseconds After Power-On?

Image
When power is applied to a microcontroller, the CPU does not immediately start executing your program. Instead, a sequence of hardware-controlled steps occurs to prepare the system for execution. Understanding this startup process helps explain how embedded systems begin running firmware. 1. Power Is Applied When the device receives power: Internal circuits begin initializing. The microcontroller enters a reset state to ensure safe startup. During this stage, the CPU is held in reset and cannot execute instructions yet. 2. Internal Oscillator Starts Most microcontrollers start using an internal RC oscillator. The reason is simple: It starts very quickly It does not require external components It allows the processor to begin operating immediately This oscillator provides the initial system clock. 3. Reset Controller Holds the CPU Even though the clock has started, the CPU is still held in reset by the reset controller. This ensures: Power is stable Clock is stable Internal hardware is ...