1/69
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Explain with the aid of diagrams the differences between a microcontroller based system and a microprocessor based system. (5 marks)
Microcontroller:
A microcontroller contains the CPU, RAM, ROM, timers and I/O peripherals on a single chip. It is low cost and is designed mainly for embedded applications.
Microprocessor:
A microprocessor mainly contains the CPU and requires external devices such as RAM, ROM, timers and I/O. It is generally more powerful and may require an operating system.

What is a microcontroller?
A microcontroller is a small general-purpose computer on a single chip. It contains a CPU, program/data memory and input/output peripherals.
What is firmware in a microcontroller?
Firmware is the program stored in the microcontroller’s program memory (ROM). It controls how the microcontroller operates for a specific application.
How is microcontroller firmware developed and programmed?
Firmware is usually written on a PC using C or Assembly language. The source code is compiled into a HEX file, and the HEX file is then downloaded to the microcontroller using a programming tool.
What are the main components inside the CPU core?
The main components inside the CPU core are:
Program Counter (PC)
Instruction Decoder
Arithmetic Logic Unit (ALU)
Registers
What is a register in a CPU?
A register is a small, fast storage location inside the CPU. Registers are used for fast temporary storage and CPU configuration.
What is the function of the Arithmetic Logic Unit (ALU)?
The ALU performs arithmetic and logical operations on data, such as addition, subtraction, AND and OR operations.
Give examples of 8-bit, 16-bit and 32-bit microcontrollers.
8-bit → AVR | 16-bit → MSP430 | 32-bit → ARM.
What applications are 8-bit, 16-bit and 32-bit microcontrollers typically used for?
8-bit: Low-cost and battery-powered devices.
16-bit: Industrial automation and motor control.
32-bit: Real-time and motion control.
What is AVR?
AVR is an 8-bit microcontroller architecture developed by Atmel and optimised for C programming.
Which microcontroller does the Arduino Uno use?
The Arduino Uno uses the AVR ATmega328.
What types of memory are used in the Arduino Uno?
Flash (ROM): 32 KB — program memory
RAM: 2 KB — data memory
EEPROM: 1 KB — non-volatile data memory
What is the function of a bootloader?
It allows application code to be uploaded to the microcontroller via USB/Serial without an external programmer.
What affects the power consumption of a microcontroller?
Clock frequency and the number of enabled peripherals.
Why is sleep mode used in a microcontroller?
To reduce power consumption by turning off the main oscillator.
What connections are typically required for a microcontroller to operate?
Power, Reset and Clock.
What happens to the I/O pins when a microcontroller starts up?
All I/O pins are set as inputs to prevent damage.
What is the basic structure of an Arduino program?
setup() — runs once at startup.
loop() — runs repeatedly.
Lecture 1 , Which AVR ports correspond to the Arduino Uno pins?”
PORTD → Digital pins 0–7
PORTB → Digital pins 8–13
PORTC → Analog pins 0–5
What is the function of the Data Direction Register (DDRx)? مهم
DDRx sets each I/O pin as an input or output.
0 = Input, 1 = Output.
What is the function of the PORTx register?
PORTx controls the output value of an I/O pin.
0 = LOW, 1 = HIGH.

What is the function of the PINx register?
PINx is used to read the logic state of an input pin.
0 = LOW, 1 = HIGH.

How do you set an AVR I/O pin as an output and turn it ON?
Set the corresponding DDR bit to 1, then set the corresponding PORT bit to 1.
وإذا طلب example، أضيفي:
DDRD = 128;
PORTD = 128;

How do you read the status of an AVR input pin?
Read the corresponding bit in the PINx register.
Example from the lecture — Pin 4:
if (PIND & 0b00010000)
📌 للامتحان: احفظي الجملة + المثال، لأنه ممكن يطلب code لقراءة pin. المثال نفسه موجود بآخر صفحة من الـLecture 1a.
How can a value be written to an 8-bit port?
Write a binary or hexadecimal value to the PORT register.
Example: PORTD = 0b10000000; or PORTD = 0x80;
How do you set Digital Pin 7 as an output and turn it ON?
DDRD = 128;
PORTD = 128;
DDRD = 128 → Pin 7 is an output.
PORTD = 128 → Pin 7 is ON.
How do you read the status of Digital Pin 4?
if (PIND & 0b00010000)
How do you set Digital Pin 1 as an output and turn it ON?
DDRD = 2;
PORTD = 2;
What is the difference between DDRx, PORTx and PINx registers?
DDRx → sets Input/Output
PORTx → sets output LOW/HIGH
PINx → reads input LOW/HIGH
Lecture 2a , What is a Yordon Diagram?
A Yordon diagram, also called a context diagram, gives a high-level description of a system and identifies its inputs and outputs.
Why are Yordon diagrams useful in microcontroller systems?
They help define all the inputs and outputs of the system at a high level and make the system easier to understand and communicate.
What is an Activity Diagram?
An Activity Diagram shows the sequence of activities/actions and the decision logic in a system.
What do decision points represent in an Activity Diagram?
Decision points represent conditions that determine which path the program follows.
What is a State Diagram?
A State Diagram shows the different states of a system and the conditions that cause transitions between states.
What is a Finite State Machine (FSM)?
A system with multiple states that changes between states based on inputs or time.
When does a system leave its current state in a Finite State Machine?
The system remains in its current state until the exit condition is achieved.
How is a Finite State Machine implemented in C?
Use a variable to store the current state and execute only the code for that state.
What is needed to move from one state to another in a Finite State Machine?
A transition condition must be satisfied.
What are the main symbols used in an Activity Diagram?
Initial state, final state, activity, decision/choice, and transition.
What is the difference between a State Diagram and an Activity Diagram?
A State Diagram shows system states and transitions. An Activity Diagram shows the sequence of actions and decisions.
What is the purpose of a switch statement when implementing a Finite State Machine?
It selects and executes the code for the current state.
What is the difference between a while loop and a for loop?
A while loop repeats while a condition is true. A for loop repeats using initialization, condition and increment.
How can you detect a button press only once, even if the button is held down?
Compare the current input with the previous input and act only when the state changes.
What is the purpose of a Yordon Diagram, Activity Diagram, and State Diagram?
Yordon → identifies inputs and outputs.
Activity → shows actions and decisions.
State → shows states and transitions.
What are the main steps when developing a microcontroller system?
Analysis → Design → Implementation
What are the two possible outcomes of a decision in an Activity Diagram?
True or False.
What determines a transition between states in a Finite State Machine?
System inputs or time.
What must a State Diagram show?
The system states and the conditions for transitions between them.
What are the main types of memory used in a microcontroller, and what are they used for? مهم جدا
ROM – stores the program.
RAM – stores data.
What is a Bus?
A bus is used to transport digital information.
Name the three types of buses and state their function.
Data Bus – transfers data.
Address Bus – selects the memory/I/O address.
Control Bus – carries control signals.
What is the function of the Arithmetic Logic Unit (ALU)?
The ALU performs arithmetic and logical operations such as addition, subtraction, multiplication and division.
What is the function of the Status Register?مهم
It stores the result/status of the last ALU operation.
What is a Register?
A register is a special memory location used to configure the MCU/peripherals or temporarily store variables.
What is the difference between Harvard and Von Neumann architectures?
Harvard – separate program and data memories with separate buses.
Von Neumann – combined program and data memory using the same buses.
What is the difference between volatile and non-volatile memory?
Volatile memory loses its data when power is removed.
Non-volatile memory retains its data when power is removed.
What is the function of the System Clock?
It provides the time base and determines the rate at which the CPU fetches, decodes and executes instructions.
What happens when the Reset input is activated?
The CPU stops running and the Program Counter is reset to 0 or a known value.
What is the function of Microcontroller I/O pins?
They connect the microcontroller to and control external devices such as sensors and relays.
How are I/O pins grouped in a microcontroller?
They are grouped into 8-bit or 16-bit ports, such as PORTA, PORTB and PORTC.
What is the difference between RISC and CISC processors?
RISC – fewer, simpler instructions that execute quickly.
CISC – more complex instructions that can take multiple clock cycles to execute.
What is the Fetch–Decode–Execute cycle?
The CPU fetches an instruction from memory, decodes it, then executes it.
What are the “Big 5” functions/statements used in Arduino programming?مهم جدا
digitalRead() – reads a digital input.
if() – makes a decision.
digitalWrite() – sets a digital output.
delay() – creates a time delay.
analogRead() – reads an analogue input using the ADC.
What does digitalRead() do? Give an example.
Reads the state of a digital input.
pin_state = digitalRead(3);
What does an if() statement do, and which operators can be used with it?
It makes a decision based on a condition.
== equal, != not equal, && AND, || OR
What does digitalWrite() do? Give an example.
Sets the state of a digital output pin to HIGH or LOW.
digitalWrite(5, HIGH);
What does delay() do? Give an example.
It pauses the program for a specified time in milliseconds.
delay(2000); = 2 seconds
What does analogRead() do? مهم
It performs an analogue-to-digital conversion and returns a 10-bit integer result.
z = analogRead(4);
Write Arduino code to flash an LED on pin 5 when digital input pin 3 is HIGH.
void setup() {
pinMode(5, OUTPUT);
}
void loop() {
if (digitalRead(3) == 1) {
digitalWrite(5, 1);
delay(1000);
digitalWrite(5, 0);
delay(1000);
}
}

Write Arduino code to flash an LED on output 5 if analogue input 0 exceeds 4.5 V.
void setup() {
pinMode(5, OUTPUT);
}
void loop() {
val = analogRead(0);
if (val > 920) {
digitalWrite(5, 1);
delay(1000);
digitalWrite(5, 0);
delay(1000);
}
}