lecture 1-2 full

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/69

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:18 PM on 8/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

70 Terms

1
New cards

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.

<p><span><strong>Microcontroller:</strong></span></p><p><span>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.</span></p><p><span><strong>Microprocessor:</strong></span></p><p><span>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.</span></p>
2
New cards

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.

3
New cards

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.

4
New cards

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.

5
New cards

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

6
New cards

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.

7
New cards

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.

8
New cards

Give examples of 8-bit, 16-bit and 32-bit microcontrollers.

8-bit → AVR | 16-bit → MSP430 | 32-bit → ARM.

9
New cards

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.

10
New cards

What is AVR?

AVR is an 8-bit microcontroller architecture developed by Atmel and optimised for C programming.

11
New cards

Which microcontroller does the Arduino Uno use?

The Arduino Uno uses the AVR ATmega328.

12
New cards

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

13
New cards

What is the function of a bootloader?

It allows application code to be uploaded to the microcontroller via USB/Serial without an external programmer.

14
New cards

What affects the power consumption of a microcontroller?

Clock frequency and the number of enabled peripherals.

15
New cards

Why is sleep mode used in a microcontroller?

To reduce power consumption by turning off the main oscillator.

16
New cards

What connections are typically required for a microcontroller to operate?

Power, Reset and Clock.

17
New cards

What happens to the I/O pins when a microcontroller starts up?

All I/O pins are set as inputs to prevent damage.

18
New cards

What is the basic structure of an Arduino program?

setup() — runs once at startup.
loop() — runs repeatedly.

19
New cards

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

20
New cards

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.

21
New cards

What is the function of the PORTx register?

PORTx controls the output value of an I/O pin.
0 = LOW, 1 = HIGH.

<p><strong>PORTx controls the output value of an I/O pin.</strong><br><strong>0 = LOW, 1 = HIGH.</strong></p>
22
New cards

What is the function of the PINx register?

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

<p><strong>PINx is used to read the logic state of an input pin.</strong><br><strong>0 = LOW, 1 = HIGH.</strong></p>
23
New cards

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;

<p><strong>Set the corresponding DDR bit to 1, then set the corresponding PORT bit to 1.</strong></p><p><span>وإذا طلب <strong>example</strong>، أضيفي:</span></p><p><span>DDRD = 128;<br>PORTD = 128;</span></p>
24
New cards

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.

25
New cards

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;

26
New cards

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.

27
New cards

How do you read the status of Digital Pin 4?

if (PIND & 0b00010000)

28
New cards

How do you set Digital Pin 1 as an output and turn it ON?

DDRD = 2;
PORTD = 2;

29
New cards

What is the difference between DDRx, PORTx and PINx registers?

DDRx → sets Input/Output
PORTx → sets output LOW/HIGH
PINx → reads input LOW/HIGH

30
New cards

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.

31
New cards

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.

32
New cards

What is an Activity Diagram?

An Activity Diagram shows the sequence of activities/actions and the decision logic in a system.

33
New cards

What do decision points represent in an Activity Diagram?

Decision points represent conditions that determine which path the program follows.

34
New cards

What is a State Diagram?

A State Diagram shows the different states of a system and the conditions that cause transitions between states.

35
New cards

What is a Finite State Machine (FSM)?

A system with multiple states that changes between states based on inputs or time.

36
New cards

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.

37
New cards

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.

38
New cards

What is needed to move from one state to another in a Finite State Machine?

A transition condition must be satisfied.

39
New cards

What are the main symbols used in an Activity Diagram?

Initial state, final state, activity, decision/choice, and transition.

40
New cards

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.

41
New cards

What is the purpose of a switch statement when implementing a Finite State Machine?

It selects and executes the code for the current state.

42
New cards

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.

43
New cards

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.

44
New cards

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.

45
New cards

What are the main steps when developing a microcontroller system?

Analysis → Design → Implementation

46
New cards

What are the two possible outcomes of a decision in an Activity Diagram?

True or False.

47
New cards

What determines a transition between states in a Finite State Machine?

System inputs or time.

48
New cards

What must a State Diagram show?

The system states and the conditions for transitions between them.

49
New cards

What are the main types of memory used in a microcontroller, and what are they used for? مهم جدا

ROM – stores the program.
RAM – stores data.

50
New cards

What is a Bus?

A bus is used to transport digital information.

51
New cards

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.

52
New cards

What is the function of the Arithmetic Logic Unit (ALU)?

The ALU performs arithmetic and logical operations such as addition, subtraction, multiplication and division.

53
New cards

What is the function of the Status Register?مهم

It stores the result/status of the last ALU operation.

54
New cards

What is a Register?

A register is a special memory location used to configure the MCU/peripherals or temporarily store variables.

55
New cards

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.

56
New cards

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.

57
New cards

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.

58
New cards

What happens when the Reset input is activated?

The CPU stops running and the Program Counter is reset to 0 or a known value.

59
New cards

What is the function of Microcontroller I/O pins?

They connect the microcontroller to and control external devices such as sensors and relays.

60
New cards

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.

61
New cards

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.

62
New cards

What is the Fetch–Decode–Execute cycle?

The CPU fetches an instruction from memory, decodes it, then executes it.

63
New cards

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.

64
New cards

What does digitalRead() do? Give an example.

Reads the state of a digital input.
pin_state = digitalRead(3);

65
New cards

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

66
New cards

What does digitalWrite() do? Give an example.

Sets the state of a digital output pin to HIGH or LOW.
digitalWrite(5, HIGH);

67
New cards

What does delay() do? Give an example.

It pauses the program for a specified time in milliseconds.
delay(2000); = 2 seconds

68
New cards

What does analogRead() do? مهم

It performs an analogue-to-digital conversion and returns a 10-bit integer result.
z = analogRead(4);

69
New cards

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);

}

}

<p>void setup() {</p><p>  pinMode(5, OUTPUT);</p><p>}</p><p>void loop() {</p><p>  if (digitalRead(3) == 1) {</p><p>    digitalWrite(5, 1);</p><p>    delay(1000);</p><p>    digitalWrite(5, 0);</p><p>    delay(1000);</p><p>  }</p><p>}</p>
70
New cards

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);

}

}