Table of Contents
Difference between MCU and MPU
Microprocessor | Microcontroller |
Has only CPU/Processing core. RAM, ROM, Flash memory are externally installed as per requirement. | Has CPU, I/O devices, Peripherals, RAM, ROM, Flash memory. |
It’s used for generic purposes like PC | Used for specific purposes for embedded systems like washing machines, and fridges. |
intel i5, i7, AMD are examples of the processor. | 8085, Atmel,stm32 are examples of the controller. |
Used for complex system/operations | Used for simple system/operations |
Consumes more power | Consumes less power |
Require more memory for operations RAM, ROM, Flash memory sizes are more. | Require less memory for operations. RAM, ROM, Flash memory sizes are more. |
Faster | Slower compared to the processor. |
More Costlier | Less Costlier |
Microcontroller block diagram
MCU(Microcontroller unit) consists of a CPU core with RAM, GPIO, ROM/Flash memory, UART(Serial Devices), and other peripheral devices.
CPU core has ALU(Arithmetic and logical unit) to perform arithmetic and logical operations, and a Control unit to synchronize the tasks with the help of sending timings and control signals.
It has buses for data, address, and control communication.
In the case of the microprocessor, it has only a processor core/CPU. Other peripherals are integrated as per requirements.
What is SOC?
– Embedded system requirements are growing. Before systems were simple. So, the microcontroller was enough to fulfill the requirements.
– Nowadays to fulfill the requirements in robotics and other domains, Need a powerful CPU.
– Companies like Xilinx, Texas Instruments, and others have started integrating required peripherals like Memory(RAM, Flash Memory), serial devices, I2C controllers, SPI controllers, USB controllers to the microprocessor.
– All the required systems or peripherals are integrated with the microprocessor is called a system on chip(SOC).
– Ex: Xilinx’s Zynq UltraScale+ MPSoC, NXP’s SAF85xx RFCMOS automotive radar System-on-Chip (SoC).
What is ALU?
– ALU(Arithmetic and logical unit) is the actual brain of the CPU.
– It performs arithmetic operations like addition and subtraction.
– It performs logical operations like AND, OR, and EX-OR.
What is the Stack Pointer(SP)?
– Stack is the memory area in the RAM used to store temporary information of the program like local variables, function formal arguments, and function return value.
– The stack pointer is the special purpose register within the CPU that contains the address of the most recent stack entry.
What is a Program Counter(PC)?
– The program is the executable which has instructions and data.
– CPU fetches the instructions one by one then decodes them and executes them.
– PC is the special purpose register of the CPU which stores the address of the next instruction which will be fetched to decode and execute.
RISC vs CISC
RISC | CISC |
Reduced instruction set computer | Complex instruction set computer |
Generic and Simple instruction set | Specific and Complex instruction set |
Generic circuitry for all the instructions | Specific microcircuitry for each complex instruction |
Mostly hardwired architecture | Mostly microcoded architecture |
Simple instructions. So, less execution time | Complex instructions. So, more execution time |
Consumes less power | Consumes more power |
Instructions are unique in size | Instructions are different in size |
The size of the instruction decoding and execution unit is relatively small | The size of the instruction decoding and execution unit is relatively large |
Processing is register intensive. So, more CPU registers | Processing is memory intensive. So, less CPU registers |
Most of the instructions take the same time and size | Instructions are grouped into varying categories of timing and sizes. |
Less number of addressing mode | More number of addressing mode |
Ex: Arm CPU | Ex: x86 intel, AMD CPUs |
What is BUS in MCU or MPU?
– The Bus is a group of wires which used to transfer information like data, addresses, or control signals.
– System Bus is generally used to communicate between CPU and Peripherals.
– Data Bus is used to transfer data between CPU and memory, CPU and I/O devices, CPU and Peripherals.
– Control Bus transfer signal. It signals which direction data should flow and synchronization of data.
– Address Bus identifies addresses of memory or I/O devices using that CPU can communicate with memory or I/O devices.
What are the instructions and data in the program?
– The program contains two things. Instructions and data.
– Instruction is the task to be performed by the CPU.
– Data is used by instructions to perform certain tasks by the CPU.
– Ex(Assembly): Mov R1, #3, here, mov is the instruction or task performed by the CPU to move data ‘3’ to the register R1.
– Ex(C): int i, int j, I = j; here, ‘i’ and ‘j’ are the data and ‘i = j(moving value of ‘j’ to the ‘i’)’ is the task or instruction to move the data.
What is von Neumann Architecture(Princeton Architecture)?
– As shown in the image, There is a common memory for instructions and data in von Neumann architecture.
– A common bus is used for instruction and data transfer.
– Instructions and data can not be transferred at the same time as both are transferred through the same bus.
– Ex: intel 8085 and 8086.
What is Harvard Architecture?
– As shown in the image, there is a separate memory for instructions and data in Harvard architecture.
– A separate bus is used for instruction and data transfer.
– Instructions and data can be transferred at the same time as both are transferred through a separate bus.
– Ex: 8051
Note: The above is a fundamental concept of von-Neumann and Harward architecture. Modern Intel and ARM CPUs use von-Neumann where the same memory for data and instructions. But, having a separate bus for instructions and data. The same is applicable to Harvard architecture as well. few CPUs are based on Harvard architecture but may not be 100% Harvard. it can be an extended version of Harvard. So, modern processors may be using a modified version of von Neumann or Harvard architecture. Even the same is applicable for RISC and CISC. Modern CPUs may not be 100% pure RISC or CISC. They can be a mixture of both.
What is machine-level language?
– Machine-level language consists of 0’s and 1’s, Which can be understood by the CPU.
– CPU is made of Gates or Transistors, Which can only understand 1’s and 0’s.
– Machine-level language is the lowest level of programming.
What is Assembly-level language?
– It is one level above machine-level language. But, it is also called low-level language.
– Humans can understand a program in assembly-level language.
– Assembler is used to convert assembly-level code to machine-level code.
– Below is the syntax of the Assembly language.
– LABEL: OPCODE OPERAND //comment
– label is a user-defined identifier representing the starting address of an instruction in the code section.
– Opcode is the operation to be performed by the CPU for the instruction.
– Operand represents registers, data, or addresses.
– A comment is a statement to help the programmers to understand syntax.
– Ex(Assembly): mov R1, #3 : here, mov is the opcode, R1 and ‘3’ is an operand.
What is higher-level programming language?
– It’s easier for humans to read and write the programs.
– It has an English type of language syntaxes.
– Easy to read, write, maintain, and debug.
– Ex: C++, JAVA