Microcontroller and Embedded Systems Test
Instructions:
1. Answer all the questions.
2. For MCQs, circle the correct answer.
3. For programming tasks, write your code clearly and concisely.
4. For design and analysis questions, explain your reasoning step by step.
Section 1: Multiple Choice Questions (50+)
What is the primary purpose of a microcontroller?
a) Perform arithmetic operations
b) Control external devices and systems
c) Display text on screen
d) Store data
Answer: b) Control external devices and systems
Which microcontroller family does the ATmega32 belong to?
a) PIC
b) ARM
c) AVR
d) 8051
Answer: c) AVR
Which addressing mode is used to load an immediate value directly into a register?
a) Direct addressing
b) Immediate addressing
c) Register addressing
d) Indirect addressing
Answer: b) Immediate addressing
Which instruction performs a logical AND operation on two registers?
a) ADD
b) AND
c) SUB
d) OR
Answer: b) AND
What is the maximum size of EEPROM in ATmega16?
a) 128 bytes
b) 512 bytes
c) 1024 bytes
d) 2048 bytes
Answer: c) 1024 bytes
Which flag in the status register is set when the result of an operation is zero?
a) Z flag
b) C flag
c) N flag
d) S flag
Answer: a) Z flag
Which of the following is a shift instruction in AVR assembly?
a) ADD
b) LSR
c) OR
d) CMP
Answer: b) LSR
What is the primary purpose of the ADC in a microcontroller?
a) To convert analog signals to digital
b) To perform arithmetic operations
c) To control external devices
d) To store data
Answer: a) To convert analog signals to digital
Which register is used to control the baud rate in USART communication?
a) UBRR
b) UCSRA
c) UCSRB
d) UDR
Answer: a) UBRR
What is the maximum number of I/O pins in ATmega32?
a) 32
b) 64
c) 128
d) 256
Answer: a) 32
Which of the following is a feature of RISC architecture?
a) Complex instructions
b) Single-clock cycle instructions
c) Multiple clock cycles per instruction
d) Large instruction set
Answer: b) Single-clock cycle instructions
What is the primary function of the interrupt system in a microcontroller?
a) Perform arithmetic operations
b) Temporarily halt program execution
c) Handle real-time clock
d) Store data
Answer: b) Temporarily halt program execution
Which of the following protocols is used for serial communication?
a) SPI
b) I2C
c) USART
d) All of the above
Answer: d) All of the above
Which memory type is typically used for temporary data storage in microcontrollers?
a) ROM
b) EEPROM
c) SRAM
d) Flash
Answer: c) SRAM
Which assembly instruction is used to store a value into a register?
a) MOV
b) LDI
c) STS
d) IN
Answer: c) STS
What is the bit width of the registers in AVR microcontrollers?
a) 8 bits
b) 16 bits
c) 32 bits
d) 64 bits
Answer: a) 8 bits
What does the `NOP` instruction do in AVR assembly?
a) No operation
b) Move data to a register
c) Jump to the next instruction
d) Set all registers to zero
Answer: a) No operation
Which of the following is an example of a non-volatile memory?
a) SRAM
b) EEPROM
c) Flash
d) Both b and c
Answer: d) Both b and c
In which mode can the USART transmit and receive data simultaneously?
a) Full Duplex
b) Half Duplex
c) Simplex
d) Synchronous
Answer: a) Full Duplex
Which of the following registers stores the result of an arithmetic operation in AVR
microcontrollers?
a) UDR
b) SREG
c) ADC
d) Z flag
Answer: b) SREG
What is the range of baud rates supported by USART in AVR?
a) 1200 to 115200
b) 1000 to 10000
c) 1 to 1000
d) 9600 only
Answer: a) 1200 to 115200
Which of the following is true about the Stack Pointer (SP) in AVR microcontrollers?
a) It is used to store temporary data
b) It points to the current position in memory
c) It is a non-volatile register
d) It holds the program counter
Answer: b) It points to the current position in memory
Which of the following instructions is used to compare two registers?
a) CMP
b) CP
c) SUB
d) AND
Answer: b) CP
Which peripheral is controlled by the Timer/Counter module in AVR?
a) USART
b) PWM
c) ADC
d) I2C
Answer: b) PWM
Which of the following instructions is used to rotate the contents of a register left through
the carry?
a) ROR
b) ROL
c) LSR
d) LSL
Answer: b) ROL
In a microcontroller, what does the ADC stand for?
a) Analog Digital Converter
b) Analog-to-Digital Converter
c) Digital Analog Converter
d) Digital-to-Analog Converter
Answer: b) Analog-to-Digital Converter
Section 2: Assembly Program Tasks (20+)
Task: Write an assembly program to add two 8-bit numbers and store the result in a register.
Task: Write an assembly program to subtract two 8-bit numbers and store the result in a
register.
Task: Write a program to rotate a register left using the ROL instruction.
Task: Write a program to check if a number is even or odd using the AND instruction.
Task: Write an assembly program to perform a logical OR between two registers.
Task: Write a program that uses a 16-bit addition between two numbers and stores the result.
Task: Write a program that compares two registers and sets a flag based on the result.
Task: Write an assembly program to set a particular bit in a register.
Task: Write an assembly program that uses the CMP instruction to compare two registers
and branches based on the result.
Task: Write a program to implement a delay using a simple loop.
Task: Write a program that uses the ADC module to read an analog value and convert it to
digital.
Task: Write a program that uses the USART to send data from a register.
Task: Write an assembly program to perform a bitwise complement on a register.
Task: Write an assembly program to move data between registers.
Task: Write a program that uses the LDI instruction to load an immediate value into a
register.
Task: Write a program that toggles a bit using the XOR operation.
Task: Write a program to implement PWM using a timer.
Task: Write an assembly program that uses interrupts to handle events.
Task: Write a program to store data in the EEPROM and retrieve it later.
Task: Write an assembly program that simulates a simple counter using registers.
Task: Write an assembly program that uses the IN instruction to read from an input port.