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

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

1. To initialize any port as an output port what value is to be given to it?
a) 0xFF
b) 0x00
c) 0x01
d) A port is by default an output port

Answer: d
Clarification: In 8051, a port is initialized by default in its output mode no need to pass any value to it.

2. Which out of the four ports of 8051 needs a pull-up resistor for using it is as an input or an output port?
a) PORT 0
b) PORT 1
c) PORT 2
d) PORT 3

Answer: a
Clarification: These pins are the open drain pins of the controller which means it needs a pull-up resistor for using it as an input or an output ports.

3. Which of the ports act as the 16 bit address lines for transferring data through it?
a) PORT 0 and PORT 1
b) PORT 1 and PORT 2
c) PORT 0 and PORT 2
d) PORT 1 and PORT 3

Answer: c
Clarification: PORT 0 and PORT 2 are used as the 16 bit address lines where PORT0 act as lower bit address lines and PORT 2 as higher bit address lines.

4. Which of the following registers are not bit addressable?
a) SCON
b) PCON
c) A
d) PSW

Answer: b
Clarification: PCON register is not a bit addressable register.

5. Which instruction is used to check the status of a single bit?
a) MOV A,P0
b) ADD A,#05H
c) JNB PO.0, label
d) CLR P0.05H

Answer: c
Clarification: JNB which stands for Jump if no bit checks the status of the bit P0.0 and jumps if the bit is 0.

6. Which addressing mode is used in pushing or popping any element on or from the stack?
a) immediate
b) direct
c) indirect
d) register

Answer: b
Clarification: If we want to push or pop any element on or from the stack then direct addressing mode has to be used in it, as the other way is not accepted.

7. Which operator is the most important while assigning any instruction as register indirect instruction?
a) $
b) #
c) @
d) &

Answer: c
Clarification: In register, indirect mode data is copied at that location where R0 or R1 are present, so @ operator is used ex. MOV @R0,A

8. What is the advantage of register indirect addressing mode?
a) it makes use of registers R0 and R1
b) it uses the data dynamically
c) it makes use of operator @
d) it is easy

Answer: b
Clarification: Register indirect addressing mode is useful if a series of data is to be assigned to that address, with the help of this quality the number of instructions decreases as a result of which performance increases.

9. Which of the following comes under the indexed addressing mode?
a) MOVX A, @DPTR
b) MOVC @A+DPTR,A
c) MOV A,R0
d) MOV @R0,A

Answer: b
Clarification: Indexed addressing mode stands for that instruction where the bits of the accumulator is also indexed with the 16 bit registers.

10. Is this a valid statement?
SETB A
a) yes
b) no
c) cant be determined
d) none of the mentioned

Answer: b
Clarification: SETB is used to set a bit of a register. A stands for accumulator which is an 8 bit register, so it is an invalid instruction.

250+ TOP MCQs on Timer Programming and Answers

AVR Micro-controller Multiple Choice Questions on “Timer Programming”.

1. In AVR, which of the following registers are not used for programming timers?
a) TCNT
b) TCON
c) TIFR
d) None of the mentioned

Answer: b
Clarification: In the timer programming of an AVR microcontroller, mainly used registers are TCNTn that stores the values of the count. TCCRn that is used to assign the mode of operation of a timer and TIFR that stores the status of various flags of the timers. Two more registers are used they are OCRn and OCFn. They are used for comparison with the count register.

2. What is the use of the prescalar in the operation of the timer?
a) for fast calculations
b) for increasing the time delay given by the timer by decreasing its frequency of operation
c) for removing the concept the reloading of count
d) for easy counter operations

Answer: b
Clarification: Prescalars are used in the operation of the timers because they generally increase the time delay generation by decreasing the frequency of its operation.

3. What modes are generally used in the operation of the timer0?
a) Normal mode
b) CTC mode
c) PWM mode
d) All of the mentioned

Answer: d
Clarification: Modes of a timer are decided by the WGM00 and WGM01 bit of the TCCR0 register and for timer0 these modes are normal mode, CTC mode, pwm mode and the fast pwm mode.

4. Timer 0 can act as a counter ____________
a) if the CS02-CS00 are 110 or 111
b) if the FOC0 bit is set to 110
c) none of the mentioned
d) all of the mentioned

Answer: a
Clarification: Timer0 can act as a counter if the CS02-CS00 bits are from 110-111.

5. Which of the timer can operate in the 16 bit condition?
a) timer0
b) timer1
c) timer2
d) all of the mentioned

Answer: b
Clarification: Timer0 and Timer2 can operate in the 8 bit condition while only Timer 1 operates in the 16 bit condition.

6. Which of the following will generate the maximum time delay?
a) f/2
b) f/4
c) f/16
d) f/32

Answer: d
Clarification: f/32 has the lowest frequency as it is divided by the maximum value of the constant, so as time and frequency are inversely related to each other so this will generate the maximum amount of machine cycle which will as a result generate the greatest delay.

7. What is the difference in the operation of a normal and a CTC mode of a timer?
a) in CTC mode PWM is used
b) here serial timer is monitored
c) in CTC mode, timer counts up until contents of TCNT register becomes equal to the contents of OCR
d) none of the mentioned

Answer: c
Clarification: In CTC mode, timer counts up until the contents of TCNT register becomes equal to the contents of OCR; then the timer will be cleared and the OCF0 flag will be set when the next clock occurs. In Normal mode, timer counts until max i.e. 0xFFH. When it rolls over from 0xFFH to 0x00H, it sets TOV(Timer Overflow).

8. We can count the pulses on the positive or the negative edge triggered pulse of the clock?
a) true
b) false
c) can’t be determined
d) depends on the circumstances

Answer: a
Clarification: A counter can count pulses on the positive or the negative edge of the clock.

9. Which pin is used for the input clock of the counter0?
a) PORTB.0
b) PORTB.1
c) PORTB.2
d) PORTB.3

Answer: a
Clarification: In ATmega32/16, T0 is the alternative function of PORTB.0. T0 is Timer/Counter 0 External Clock Input.

10. Which resource provides the clock pulse to AVR timers if CS02-00=6?
a) internal clock of the AVR
b) external clock of the AVR
c) none of the mentioned
d) all of the mentioned

Answer: b
Clarification: The External clock is used for providing the pulse to the AVR timers if CS02-00=6.

250+ TOP MCQs on Low Power Modes and Answers

MSP430 Microcontroller Mcqs on “Low Power Modes”.

1. There are how many MSP430’s low power modes available in the chip?
a) two
b) three
c) four
d) five

Answer: d
Clarification: There are five low power modes available in the MSP430, out of which two are rarely employed in the current devices.

2. Which of the following are the low power modes?
a) LPM0
b) LPM3
c) LPM4
d) All of the mentioned

Answer: d
Clarification: LPM0, LPM3, LPM4 all are the low power modes that are available in the MSP430.

3. Which of the following modes is also known as the RAM retention mode?
a) LPM0
b) LPM3
c) LPM4
d) All of the mentioned

Answer: c
Clarification: LPM4 is known as the RAM retention mode. Here, the CPU and all clocks are disabled, I ≈ 0.1A. The device can be woken only by an external signal.

4. Waking a device simply means that switching that device’s operation from a low power mode to an active mode.
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: a
Clarification: When a device is operating in a low power mode, it can also be assumed that the device is sleeping, so waking a device simply means to turn that device’s operation from a low power mode to an active mode.

5. When an interrupt is accepted, the contents of the status register are ___________
a) set
b) reset
c) remains the same
d) cant be said

Answer:b
Clarification: When an interrupt is accepted, the contents of the status register are cleared, it actually puts the processor in the active mode.

6. Which of the following basic clock modules supplies clock signals to the MSP430?
a) ACLK
b) MCLK
c) SMCLK
d) All of the mentioned

Answer: d
Clarification: All of the mentioned options are correct. The basic clock module supplies the MSP430 with three clock signals as follows:
ACLK → crystal oscillator signal
MCLK → controllers main system clock
SMCLK → sub main system clock used to run the peripheral module function.

7. _ _low_ power_mode_0() states the processor to __________
a) enable the interrupt
b) disable the interrupt
c) nothing
d) to go in an active mode

Answer: a
Clarification: _ _low_ power_mode_0() puts the processor in the LPM0 mode.

8. More power can be saved by using low_power mode 0 than low_power mode 3.
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: b
Clarification: More power is saved in low_ power mode 3.

9. _BIC_SR_IRQ() is used to _______________
a) set the particular bits of the SR
b) reset the particular bits of the SR
c) any of the above mentioned depending on the conditions
d) none of the mentioned

Answer: b
Clarification: _BIC_SR_IRQ() is used to clear the bits of the SR.

10. The only clock that runs in the LPM3 is the ___________
a) MCLK
b) ACLK
c) CLK
d) None of the mentioned

Answer: b
Clarification: The only clock that runs in the LPM3 is the ACLK.

250+ TOP MCQs on Arithmetic and Logic Instructions and Answers

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

1. When we add two numbers the destination address must always be.
a) some immediate data
b) any register
c) accumulator
d) memory

Answer: c
Clarification: For addition purposes, the destination address must always be an accumulator. Example- ADD A,R0; ADD A, @R1; ADD A,@ DPTR

2. DAA command adds 6 to the nibble if:
a) CY and AC are necessarily 1
b) either CY or AC is 1
c) no relation with CY or AC
d) CY is 1

Answer: b
Clarification: DAA command adds 6 to the nibble if any of the nibbles becomes greater than 9.

3. If SUBB A,R4 is executed, then actually what operation is being applied?
a) R4+A
b) R4-A
c) A-R4
d) R4+A

Answer: c
Clarification: SUBB command subtracts with borrow the contents of an accumulator with that of the register or some immediate value. So A-R4 is being executed.

4. A valid division instruction always makes:
a) CY=0,AC=1
b) CY=1,AC=1
c) CY=0,AC=0
d) no relation with AC and CY

Answer: c
Clarification: When we divide two numbers then AC and CY become zero.

5. In 8 bit signed number operations, OV flag is set to 1 if:
a) a carry is generated from D7 bit
b) a carry is generated from D3 bit
c) a carry is generated from D7 or D3 bit
d) a carry is generated from D7 or D6 bit

Answer: d
Clarification: In 8 bit operations, if a carry is generated from D6 or D7 bit, then OV flag is set to 1.

6. In unsigned number addition, the status of which bit is important?
a) OV
b) CY
c) AC
d) PSW

Answer: b
Clarification: If unsigned numbers operations are involved, then the status of CY flag is important and in signed number operation the status of OV flag is important.

7. Which instructions have no effect on the flags of PSW?
a) ANL
b) ORL
c) XRL
d) All of the mentioned

Answer: d
Clarification: These instructions are the arithmetic operations and the flags are affected by the data copy instructions, so all these instructions don’t affect the bits of the flag.

8. ANL instruction is used _______
a) to AND the contents of the two registers
b) to mask the status of the bits
c) all of the mentioned
d) none of the mentioned

Answer: c
Clarification: ANL instruction is used to AND the contents of the two registers and is also used to mask the status of the bits of the register.

9. CJNE instruction makes _______
a) the pointer to jump if the values of the destination and the source address are equal
b) sets CY=1, if the contents of the destination register are greater then that of the source register
c) sets CY=0, if the contents of the destination register are smaller then that of the source register
d) none of the mentioned

Answer: d
Clarification: In CJNE command, the pointer jumps if the values of the two registers are not equal and it resets CY if the destination address is larger then the source address and sets CY if the destination address is smaller then the source address.

10. XRL, ORL, ANL commands have _______
a) accumulator as the destination address and any register, memory or any immediate data as the source address
b) accumulator as the destination address and any immediate data as the source address
c) any register as the destination address and accumulator, memory or any immediate data as the source address
d) any register as the destination address and any immediate data as the source address

Answer: a
Clarification: These commands have accumulator as the destination address and any register, memory or any immediate data as the source address.

250+ TOP MCQs on Interrupt Programming and Answers

AVR Micro-controller Multiple Choice Questions on “Interrupt Programming”.

1. On reset, what are the contents of the SREG register?
a) 00h
b) ffh
c) 1fh
d) 11h

Answer: a
Clarification: On reset, all the interrupts are masked and so the contents of the SREG register is also set to zero as it shows the status of the flags.

2. TIMSK register is used for?
a) knowing the status of the timer count
b) used for masking the interrupts flags of the Timer0, Timer1 and Timer2
c) it is used for enabling all the timer interrupts
d) it is used for resetting the value of the interrupts

Answer: b
Clarification: TIMSK is used for masking the interrupt flags of the timers. They mask the bits of the timer flags if the D7 bit of the SREG register is set to 1 or when firstly all interrupts are enabled.

3. Why RETI instruction be the last instruction of ISR?
a) because it returns with carry
b) because it returns to the main program with all the flags of the SREG raised
c) because it returns to the main program where interrupt is generated and set the global interrupt enable bit in SREG
d) none of the mentioned

Answer: c
Clarification: When an interrupt occurs, the global interrupt enable bit is cleared. If global interrupt enable is cleared it means interrupts are disabled. RETI instruction must last instruction of ISR because it returns to the main program where interrupt is generated and sets the global interrupt enable bit in SREG.

4. In AVR what is the ISR address for an external hardware interrupt?
a) 0002h
b) 0004h
c) 0006h
d) all of the mentioned

Answer: d
Clarification: The ISR addresses for the external hardware interrupts are 0002h, 0004h, 0006h.

5. What is the address in the interrupt service routine assigned for the timer0 overflow flag?
a) 0012h
b) 000Ah
c) 0016h
d) all of the mentioned

Answer: c
Clarification: 0016h is the address in the interrupt service routine assigned for the timer0 overflow flag.

6. Is the same address is assigned for the timer0 and timer1 overflow flag in the interrupt vector table of the interrupts?
a) true
b) false
c) can’t be determined
d) depends on the situation

Answer: b
Clarification: Different addresses are assigned for Timer0 and Timer1 overflow flags in the interrupt vector table. They are 0016h and 0012h for timer0 and timer1 respectively.

7. External hardware interrupts are assigned to which pins of the atmega32?
a) PORTD.2
b) PORTD.3
c) PORTB.2
d) All of the mentioned

Answer: d
Clarification: There are three external hardware interrupts in the atmega32 microcontrollers. They are assigned to bits PORTD.2, PORTD.3 and PORTB.2.

8. Which register is responsible for handling all the external hardware interrupts?
a) TIMSK
b) GICR
c) MCUCR
d) IVCE

Answer: b
Clarification: GICR register is responsible for all the external hardware interrupts in the AVR.

9. By default, INT0-INT2 interrupts are?
a) edge triggered
b) level triggered
c) all of the mentioned
d) none of the mentioned

Answer: b
Clarification: By default, INT0-INT2 are the level triggered pulses. The low level of the pulse generates the interrupt.

10. What will happen in that condition, if an interrupt occurs while the microcontroller is serving any other interrupt?
a) both the interrupts will be handled simultaneously
b) the interrupt which is being done first will be served first
c) the interrupt that is more priority in the interrupt vector table will be served first
d) the interrupt having low priority in the interrupt vector table will be served first

Answer: c
Clarification: If two or more interrupts occur simultaneously then the interrupt that is having more priority in the interrupt vector table will be served first.

250+ TOP MCQs on Digital Inputs, Outputs and Delays and Answers

Basic MSP430 Microcontroller Questions and Answers on “Digital Inputs, Outputs and Delays”.

1. Which of the following registers are related to port P1?
a) P1SEL
b) P1DIR
c) P1IES
d) All of the mentioned

Answer: d
Clarification: All of the mentioned registers are related to Port1.
P1SEL → Port Select Port pins are often multiplexed with other peripheral module functions. P1SEL and P1SEL2 bit is used to select the pin function – I/O port or peripheral module function.
P1DIR → Direction register selects the direction of the corresponding I/O pin.
P1IES → Interrupt Edge Select.

2. A pull-up or pull-down resistor ___________
a) removes the full output drive on the output pin
b) gives only a feeble current through the pull-up to resistor
c) removes the full output drive on the output pin & gives only a feeble current through the pull-up to resistor
d) none of the mentioned

Answer: c
Clarification: A pull-up or pull-down resistor is used to remove the full output drive on the output pin. It also gives a feeble current through the pull-up to a resistor.

3. P1.3 is the ___________
a) input CCI1A to Timer_A
b) is connected to the voltage reference VREF of SD16_A
c) is output TA0 from Timer_A
d) are digital inputs with pull-up resistors

Answer: b
Clarification: P1.3 is connected to the voltage reference VREF of SD16_A.

4. What actually is SD16_A?
a) it is an interrupt
b) it is a timer
c) it is an analog to Digital Converter
d) it is a serial communication module

Answer: c
Clarification: SD16_A is an analog to the digital module.

5. P1IE and P1IES are registers that are used to ___________
a) control the Port1 digital i/o ports
b) control the Port1 interrupts
c) control the Port1 serial communication interfaces
d) all of the mentioned

Answer: b
Clarification: P1IE and P1IES both registers are used to control the Port1 interrupts.

6. Unused pins must never be left unconnected in their default state as inputs.
a) true
b) false
c) cant be said
d) depends on the conditions

Answer: a
Clarification: Unused pins must never be left unconnected in their default state as inputs. This follows a general rule that inputs to CMOS must never be left unconnected or “floating”.

7. Which of the following is an effect of a Schmidt trigger?
a) it turns slowly varying inputs, which might cause problems while they pass slowly through the undefined range of input voltages, into abrupt, clean logical transitions
b) It eliminates the effect of noise on the input, provided that it is not large enough to span the gap between the upward and downward thresholds
c) none of the mentioned
d) all of the mentioned

Answer: d
Clarification: Schmidt trigger has two of the above mentioned effects in it.

8. To ensure that a negative fluctuation does not trigger an unwanted downward transition by pulling the input down through VIT−, we must choose
a) minimum hysteresis
b) maximum hysteresis
c) all of the mentioned
d) none of the mentioned

Answer: a
Clarification: To ensure that a negative fluctuation does not trigger an unwanted downward transition by pulling the input down through VIT−, we must choose a minimum hysteresis of 0.3V.

9. The SPDT switch can be used as a ___________
a) detecting circuit
b) debouncing circuit
c) devaluing circuit
d) degenerating circuit

Answer: b
Clarification: The SPDT(single pole, double pole) switch can be used as a debouncing circuit of a switch.

10. Debouncing can be carried out at a hardware as well as the software end?
a) yes
b) no
c) cant be said
d) depends on the conditions

Answer: a
Clarification: Debouncing can be carried out at both the fronts both at the software as well as the hardware front, to carry out the process appropriately.