250+ TOP MCQs on I/O Port Programming and Addressing Modes

AVR Micro-controller Multiple Choice Questions on “I/O Port Programming and Addressing Modes”.

1. In AVR, which registers are there for the I/O programming of ports?
a) PORT
b) PIN
c) DDR
d) All of the mentioned

Answer: d
Clarification: For I/O programming of the ports in AVR microcontrollers, there are basically three main registers. They are PORT, PIN, DDR, so all of the mentioned is the right option.

2. The data will not go from the port registers to the pin unless:
a) DDR register of that port is set to 0
b) PORT register of that port is set to 1
c) DDR register of that port is set to 1
d) PORT register of that port is set to 0

Answer: c
Clarification: The data will not go from the port registers to the pin unless the DDR register of that port is set to 1 because by doing this we make that port an output port after which data can be taken from the PORT registers to the pin.

3. On reset DDR registers of all ports are set to:
a) 0
b) 1
c) None of the mentioned
d) 0 & 1

Answer: a
Clarification: On reset, the DDR registers of all the ports are set to 0 which means that the by default all ports are set as input ports.

4. Which of the following statements are correct?
a) PIN register of a port is used to bring data into CPU from pins
b) PORT register is used to send data out to pins
c) DDR register is used to control the direction of a port
d) All of the mentioned

Answer: d
Clarification: There are three registers that are related to a port. They are PIN, PORT, DDR. PIN register is used to bring data into CPU from pins, PORT register is used to send data to pins and DDR register is used to control the direction of the data transfer. So all are the right options.

5. In the AVR family, all I/O ports have 8 pins?
a) true
b) false
c) none of the mentioned
d) can’t be determined

Answer: b
Clarification: In the AVR family, all I/O ports don’t have 8 pins. Number of I/O pins depends on the total number of pins of the controller. Eg. ATtinyxx is an 8 pin controller and it has 6 I/O pins.

6. Which of the following is not a single bit instruction in AVR?
a) SBI
b) PORT
c) CBI
d) All of the mentioned

Answer: b
Clarification: PORT is not an instruction. It is the name of a register in AVR.

7. Which of the following is correct about the SBIS instruction?
a) it is used to monitor status of bit in I/O register
b) it is a byte oriented instruction
c) It is a 4 byte instruction
d) all of the mentioned

Answer: a
Clarification: SBIS (Skip if Bit in I/O register Set) is used to check status of bit in I/O register. If the bit mentioned in the instruction is SET or HIGH then the controller will skip the immediate next instruction.

8. Instruction CBI PORTB,1 means
a) clearing the PORTB register
b) clearing the first bit of the PORTB register
c) setting the PORTB register
d) setting the first bit of the PORTB register

Answer: b
Clarification: CBI PORTB, 1 means to clear the first bit of the PORTB register. It is a bit oriented instruction.

9. Which of the following instruction can be used to toggle a bit of the PORT?
a) SBI
b) CBI
c) SBI & CBI
d) None of the mentioned

Answer: c
Clarification: If SBI and CBI are used together, then they can be used to toggle a bit of a port successfully.

10. What is the main function of the SBIC instruction?
a) it is used to clear a particular bit of a port
b) it is used to jump unconditionally
c) it is used to skip the instruction if a particular bit of a port is zero
d) none of the mentioned

Answer: c
Clarification: SBIC (Skip if Bit in I/O register Clear) is used to check status of bit in I/O register. If the bit mentioned in the instruction is CLEAR or LOW then the controller will skip the immediate next instruction.

250+ TOP MCQs on MSP430 Functions and Subroutine and Answers

MSP430 Microcontroller Quiz on “Functions and Subroutine”.

1. Which instruction is used to call functions?
a) MOV
b) GO
c) CALL
d) All of the mentioned

Answer: c
Clarification: CALL instruction is used for going to a particular address in MSP430. It actually causes the pointer to jump at a particular address and push the current address of the PC to the stack.

2. ret instruction is used for _________
a) determining the end of the program
b) for returning back from the subroutine to the main program
c) for transferring data from one place to another
d) none of the mentioned

Answer: b
Clarification: Ret instruction is basically used for returning back from a subroutine. It actually pops the top address from the stack and moves that address to its PC, so that it now returns to the main program and continue the execution normally.

3. According to conventions being followed, R12 to R15 are used for _________
a) parameter passing
b) preserved for call
c) all of the mentioned
d) none of the mentioned

Answer: a
Clarification: According to the conventions, R12 to R15 are used for parameter passing and hence are not preserved for the call.

4. We can store the temporary results across a call instruction with the help of which of the following registers
a) R1-R4
b) R4-R11
c) R12-R15
d) All of the mentioned

Answer: b
Clarification: Temporary results are stored by the registers R4-R11.

5. Can we allocate variables on the stack?
a) yes
b) no
c) cant be said
d) depends on the conditions

Answer: a
Clarification: Yes, we can allocate the variables on the stack, it is a very effective way of storing the variables.

6. Which registers are reserved for passing the parameters to a subroutine and then returning the final result?
a) R1-R4
b) R4-R11
c) R12-R15
d) All of the mentioned

Answer: c
Clarification: Originally, R12-R15 registers are reserved for passing the parameters to a subroutine and then returning the final result.

7. What actually is the order of stack frame for a parameter to pass to a subroutine?
a) parameter passed to a subroutine
b) return address
c) saved copies of registers(R4-R11)
d) all of the mentioned

Answer: d
Clarification: All the steps i.e. parameter passed to a subroutine, return address, saved copies of registers(R4-R11), local variables in subroutines are required for passing a parameter to a subroutine.

8. When any subroutine is called, then the first value of stack will be
a) value of PC
b) the return address
c) none of the mentioned
d) both are one and the same things

Answer: d
Clarification: When any subroutine is called then the first place of the stack will be filled with the return address, or the address of the PC so that the pointer may return back to its appropriate place after the return instruction of the subroutine.

9. Which of the following instruction/s is/are used to return back to the main program after the subroutine is completed?
a) ret
b) reti
c) ret and reti
d) none of the mentioned

Answer: c
Clarification: For returning back from the subroutine, both ret and reti can be used, the main difference between the two is that reti just resets the interrupt flag before the return, so that the interrupt can occur again.

10. Is the approach of making subroutines effective or not?
a) yes
b) no
c) cant be said
d) depends on the conditions

Answer: a
Clarification: The approach of making subroutine is indeed very effective, as with its help we don’t need to retrace/write a particular set of codes again and again. It makes our approach modular.

250+ TOP MCQs on MSP430 Asynchronous Serial Communication

MSP430 Microcontroller Assessment Questions and Answers on “Asynchronous Serial Communication”.

1. Asynchronous serial communication usually requires two wires for each direction plus a common ground.
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: b
Clarification: Asynchronous serial communication usually requires only a single wire for each direction plus a common ground.

2. In an asynchronous mode of transmission, usually the data is sent along with the
a) the start bit
b) the stop bit
c) the start & stopbit
d) none of the mentioned

Answer: c
Clarification: In an asynchronous mode of transmission, both the start and the stop bits are present that are basically used for intimating the other terminal that whether the data had received correctly the other destination or not.

3. The _____ rate gives the frequency at which the bits are transmitted on the line.
a) bit rate
b) packet rate
c) baud rate
d) data rate

Answer: c
Clarification: Baud rate is the rate which determines us the frequency at which the bits are transmitted on the line.

4. Baud rate is the reverse of the ________
a) baud time
b) baud period
c) bit time
d) bit period

Answer: b
Clarification: Baud rate is the reverse of the baud period.

5. Clock is transmitted in the asynchronous communication?
a) yes
b) no
c) cant be said
d) depends on the conditions

Answer: b
Clarification: No clock is transmitted in the asynchronous communication, so the transmitter and the receiver are allowed to work independently at their own terminals.

6. A framing error occurs is the bit is ________
a) high
b) low
c) same
d) changed

Answer: b
Clarification: Framing error occurs if the bit is low.

7. What is the non return to zero format?
a) the bits are either high or low and have no gaps between them
b) the bits are either high or low and have gaps between them
c) the bits are high and have gaps between them
d) the bits are low and have no gaps between them

Answer: a
Clarification: Non-return to zero format represents a format in which the bits are either high or low and have no gaps between them.

8. LSB is sent first in case of the non return to zero format.
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: a
Clarification: In non-return to zero format, normally LSB is sent first.

9. There are _______ clocks in the USCI_A.
a) 1
b) 2
c) 3
d) 4

Answer: c
Clarification: they are 3 clocks in the USCI_A. They are BRCLK, BITCLK and BITCLK16.

10. BITCLK16 is the ________
a) sampling clock in the undersampling mode
b) sampling clock in the oversampling mode
c) quantising clock in the undersampling mode
d) quantising clock in the oversampling mode

Answer: b
Clarification: BITCLK16 is the sampling clock in the oversampling mode.

250+ TOP MCQs on Jump, Loop and Call Instructions and Answers

8051 Micro-controller Multiple Choice Questions on “Jump, Loop and Call Instructions”.

1. “DJNZ R0, label” is ________ byte instruction.
a) 2
b) 3
c) 1
d) Can’t be determined

Answer: a
Clarification: DJNZ is 2-byte instruction. This means jump can be of -128 to +127 locations with respect to PC. Here -128 means upward or backward jump and +127 means downward or forward jump.

2. JZ, JNZ, instructions checked content of _______ register.
a) DPTR
b) B
c) A
d) PSW

Answer: c
Clarification: JZ and JNZ instructions checked the content of A register and if condition was satisfied or true then jump to target address.

3. Calculate the jump code for again and here if code starts at 0000H

MOV R1,#0
MOV A,#0
MOV R0,#25H
AGAIN:ADD A,#0ECH
JNC HERE
HERE: INC R1
DJNZ R0,AGAIN 
MOV R0,A
END

a) F3,02
b) F9,01
c) E9,01
d) E3,02

Answer: c
Clarification: Loop address is calculated by subtracting destination address and the address next to the source address.
So here if we start with 0000H
then source address is 0008H and the destination address is 0004H
So loop address is 04-0A=E9

4. When the call instruction is executed the topmost element of stack comes out to be
a) the address where stack pointer starts
b) the address next to the call instruction
c) address of the call instruction
d) next address of the stack pointer

Answer: b
Clarification: The topmost element of the stack is the address of the instruction next to the call instruction so that when RET is executed then PC is filled with that address and so the pointer moves to the main program and continue with its routine task.

5. LCALL instruction takes
a) 2 bytes
b) 4 bytes
c) 3 bytes
d) 1 byte

Answer: c
Clarification: LCALL instruction moves the pointer to a 16 bit address so it is a 3 byte instruction.

6. Are PUSH and POP instructions are a type of CALL instructions?
a) yes
b) no
c) none of the mentioned
d) cant be determined

Answer: b
Clarification: PUSH and POP instructions are not CALL instructions because in POP and PUSH instructions the pointer does not move to any location specified by its address which is the fundamental of CALL instruction, so it is not a type of CALL instruction.

7. What is the time taken by one machine cycle if crystal frequency is 20MHz?
a) 1.085 micro seconds
b) 0.60 micro seconds
c) 0.75 micro seconds
d) 1 micro seconds

Answer: b
Clarification: Time taken by one machine cycle is calculated by the inverse of a (crystal frequency) /12

8. Find the number of times the following loop will be executed

MOV R6,#200
BACK:MOV R5,#100
HERE:DJNZ R5, HERE
DJNZ R6,BACK
END

a) 100
b) 200
c) 20000
d) 2000

Answer: c
Clarification: It will be executed 200*100 times.

9. What is the meaning of the instruction MOV A,05H?
a) data 05H is stored in the accumulator
b) fifth bit of accumulator is set to one
c) address 05H is stored in the accumulator
d) none of the mentioned

Answer: c
Clarification: If we need to store the address in the accumulator, then directly the address is moved to it unlikely of using # used for storing data in any register.

10. Do the two instructions mean the same?

1) BACK:  DEC R0            
          JZ BACK
2) BACK:  DJNZ RO, BACK

a) yes
b) no
c) cant be determined
d) yes and the second one is preferred

Answer: b
Clarification: In the first statement, when the decrements approach zero then the jump moves back and in the second statement, when the result after decrements is not zero, then it jumps back.

250+ TOP MCQs on Arithmetic and Logic Instructions and Answers

AVR Micro-controller Multiple Choice Questions on “Arithmetic and Logic Instructions”.

1. In AVR microcontrollers, ADD instruction affects the status of which of the following bits of a status register?
a) Z
b) C
c) N
d) All of the mentioned

Answer: d
Clarification: ADD instruction affects the status of Z, C, N, V, H and S bits of a status register.

2. ADC instruction is used for?
a) addition of two 16 bit numbers
b) analog to digital conversion
c) automatic digital control
d) none of the mentioned

Answer: a
Clarification: ADC instruction can be used for addition of two 16 bit numbers as here two 8 bit numbers are added simultaneously along with the carry coming from the previous 8 bits. So it can be used for the addition of two 16 bit numbers.

3. AVR supports which of the following mentioned subtraction instructions?
a) SUB
b) SBC
c) SUBI
d) All of the mentioned

Answer: d
Clarification: AVR supports five types of subtraction instructions. They are SUB, SBC, SUBI, SBCI, SBIW.

4. What steps are involved when we subtract two numbers present at two different locations?
a) take the two’s complement of the subtrahend
b) add it to the minuend
c) invert the carry
d) all of the mentioned

Answer: d
Clarification: When we need to subtract two numbers present at two different locations then firstly we need to take the 2’s complement of the subtrahend, then we add it with the minuend and then when we invert the carry then the complete procedure of the subtraction is completed.

5. In executing subtraction based instructions, state the role of the C flag?
a) if C=1, the result is negative
b) if C=1, the result is positive
c) none of the mentioned
d) all of the mentioned

Answer: a
Clarification: If the C flag comes out to be 1, then the result is assumed to be negative and vice versa.

6. Which of the following is correct about the MUL instruction?
a) it is a byte-by-byte multiplication instruction
b) the product is stored in two registers R1 and R0
c) all of the mentioned
d) none of the mentioned

Answer: c
Clarification: MUL instruction is a byte-by-byte multiplication instruction whose result is stored in two registers R1 and R0.

7. In AVR, when is the V flag set?
a) there is a carry from D7 bit
b) there is a carry from D6 to D7 bit
c) when carry is generated only from D6 to D7 or carry is generated only from D7
d) none of the mentioned

Answer: c
Clarification: In AVR, V i.e. Overflow flag is set when carry is generated only from D6 to D7 or carry is generated only from D7. Overflow flag is used to detect errors in signed arithmetic operations.

8. To set the bits of a register R1 to 1, we must OR the contents of the register with?
a) 00H
b) 11H
c) FFH
d) 0FH

Answer: c
Clarification: To make the contents of the register R1 to 1 we must OR the contents of that register with FFH because according to Or algorithm 0+1=1 and 1+0=1.

9. CP instruction alters the value of the register?
a) true
b) false
c) none of the mentioned
d) can’t be said

Answer: b
Clarification: CP command is used to compare the contents of the two registers. It doesn’t actually alter the value of the register.

10. What is right about the ROR instruction?
a) it rotates the contents of the register left to right
b) it rotates the contents of the register from right to left
c) it rotates the contents of the register from left to right through carry
d) it rotates the contents of the register from right to left through carry

Answer: c
Clarification: ROR instruction is used to rotate the contents of the register from left to right through carry.

250+ TOP MCQs on MSP430 Interrupts and Answers

MSP430 Micro-controller Multiple Choice Questions on “Interrupts”.

1. MSP430 uses vectored interrupts?
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: a
Clarification: MSP430 has vectored interrupts i.e. the address of each ISR is stored in a vector table, that’s why it has vectored interrupts.

2. Which of the following is true?
a) interrupts are required to wake a CPU from sleep
b) same vector address associated with multiple flags
c) most interrupts are maskable
d) all of the mentioned

Answer: d
Clarification: All of the above mentioned statements are true i.e. interrupts are required to wake a CPU from sleep, same vector address associated with multiple flags and most of the interrupts are maskable.

3. After the interrupt has occurred, the stack is filled with ______________
a) return address
b) status register
c) return address & status register
d) none of the mentioned

Answer: c
Clarification: When an interrupt had occurred, the top place of the stack is filled with the return address, so that immediately after the reti instruction the pointer moves to the main program, the stack is also filled with the bits of the status register so that all the temporary values get stored in it.

4. What is the purpose of __interrupt() function?
a) it is used to enable the interrupt
b) it is used to disable the interrupt
c) it denotes that the routine is an ISR
d) all of the mentioned

Answer: c
Clarification: The purpose of __interrupt() function is to denote that the routine is an ISR.

5. What is the purpose of .intvec assembler directive?
a) it creates an interrupt vector entry that points to an interrupt routine name
b) one is used for storage, other for display
c) one stores locally other stores globally
d) the two are the same

Answer: a
Clarification: The .intvec directive creates an interrupt vector entry that points to an interrupt routine name.

6. For enabling any interrupt, firstly _____________
a) GIE=0
b) GIE=1
c) None of the mentioned
d) GIE=0 & 1

Answer: b
Clarification: If GIE is set to 1, then only other hardware interrupts are enabled.

7. Nonmaskable vectors are stored at different vector locations?
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: b
Clarification: Nonmaskable interrupts are stored in the same vector location, it may be of higher or the lower priority.

8. Which of the following can generate a nonmaskable interrupt?
a) access violation to flash memory, ACCVIFG
b) timer_A interrupt
c) compare / capture interrupt
d) all of the mentioned

Answer: a
Clarification: A nonmaskable interrupt is generated by an access violation to flash memory, ACCVIFG.

9. External RST/NMI pin is a nonmaskable interrupt?
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: a
Clarification: Yes, external RST/NMI pin is a nonmaskable interrupt( The function of the RST/NMI pin is configured in the control register for the watchdog timer module, WDTCTL).

10. How many cycles are used by MSP430, when reti instruction is executed?
a) 3
b) 4
c) 5
d) depends on the conditions

Answer: c
Clarification: When reti instruction is executed, five cycles are used because it firstly pops the stack register completely and then takes the top of the stack into the PC to return to the next address of the main program.