Unit 2 - Practice Quiz

ECE227 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does the acronym "PIC" stand for in the context of microcontrollers?

Introduction to PIC microcontrollers Easy
A. Processor for Industrial Control
B. Peripheral Interface Controller
C. Programmable Integrated Circuit
D. Personal Integrated Computer

2 Most PIC microcontrollers are based on which computer architecture?

PIC architecture Easy
A. Stack architecture
B. Harvard architecture
C. Von Neumann architecture
D. Princeton architecture

3 What is the primary role of the WREG (Working Register) in a PIC microcontroller?

PIC WREG register Easy
A. To store the program's starting address
B. To act as a primary accumulator for arithmetic and logic operations
C. To point to the next instruction to be executed
D. To store the status of the CPU

4 The entire data memory space in a PIC microcontroller is referred to as the...

File register Easy
A. File Register
B. Program Memory
C. Stack Register
D. Instruction Register

5 Which bit in the STATUS register is set to 1 if the result of an arithmetic operation is zero?

Status Register Easy
A. DC (Digit Carry flag)
B. OV (Overflow flag)
C. Z (Zero flag)
D. C (Carry flag)

6 What is the main function of the Program Counter (PC) in a PIC microcontroller?

Program counter and program ROM space in PIC Easy
A. It counts the number of clock cycles
B. It holds the address of the next instruction to be executed
C. It stores the main program code
D. It stores the result of the last calculation

7 The 'F' in the part number PIC18F458 indicates that the microcontroller uses what type of program memory?

Introduction to PIC18F458 Easy
A. Fast RAM
B. Flash
C. Field-Programmable
D. Ferroelectric RAM

8 What is the primary purpose of the PIC's configuration registers (also known as configuration bits)?

PIC configuration register Easy
A. To hold the program code for debugging
B. To store the results of ALU operations
C. To set up fundamental device options before the main program runs
D. To store temporary user data during runtime

9 Which company is the primary developer and manufacturer of the PIC microcontroller family?

Introduction to PIC microcontrollers Easy
A. AMD
B. Intel
C. Microchip Technology Inc.
D. Texas Instruments

10 PIC microcontrollers are based on which instruction set architecture?

PIC architecture Easy
A. MISC (Minimal Instruction Set Computer)
B. RISC (Reduced Instruction Set Computer)
C. VLIW (Very Long Instruction Word)
D. CISC (Complex Instruction Set Computer)

11 What is the bit-size of the WREG register in most 8-bit PIC microcontrollers, including the PIC18 family?

PIC WREG register Easy
A. 32 bits
B. 16 bits
C. 4 bits
D. 8 bits

12 Which registers in the file register map are used to control the microcontroller's peripherals?

File register Easy
A. General Purpose Registers (GPRs)
B. Special Function Registers (SFRs)
C. Program Counter (PC)
D. Working Register (WREG)

13 The 'C' flag in the PIC's STATUS register is set to indicate what condition?

Status Register Easy
A. The result was a negative number
B. The operation resulted in zero
C. A carry-out from the most significant bit (MSb) of an addition
D. The CPU clock has stopped

14 What kind of information is stored in the Program ROM space of a PIC microcontroller?

Program counter and program ROM space in PIC Easy
A. The user's application code (instructions)
B. Real-time sensor data
C. Hardware configuration settings
D. Temporary variables

15 The PIC18F458 is well-suited for automotive applications primarily because it includes an on-chip module for which communication protocol?

Introduction to PIC18F458 Easy
A. Ethernet
B. Wi-Fi
C. CAN (Controller Area Network)
D. Bluetooth

16 What is the main benefit of having separate buses for program and data memory in the Harvard architecture?

PIC architecture Easy
A. It reduces the cost of the microcontroller
B. It simplifies the programming model
C. It allows for larger program memory
D. It allows the CPU to fetch an instruction and access data simultaneously

17 Which type of registers within the file register are used by the programmer for general data storage, like variables?

File register Easy
A. Configuration Registers
B. General Purpose Registers (GPRs)
C. Special Function Registers (SFRs)
D. Status Register (STATUS)

18 How wide is the Program Counter in the PIC18 microcontroller family?

Program counter and program ROM space in PIC Easy
A. 8 bits
B. 21 bits
C. 13 bits
D. 16 bits

19 Which of the following best describes a microcontroller like a PIC?

Introduction to PIC microcontrollers Easy
A. A single chip containing a processor, memory, and I/O peripherals
B. A graphics processing unit (GPU)
C. A memory chip designed only for data storage
D. A high-speed CPU for a personal computer

20 In the PIC18 STATUS register, what does the 'N' flag indicate?

Status Register Easy
A. A non-zero result occurred
B. A number overflowed
C. The result of an operation is negative
D. A new instruction is ready

21 A PIC18 microcontroller has a 21-bit Program Counter. What is the maximum size of the program memory (ROM) that can be directly addressed?

Program counter and program ROM space in PIC Medium
A. 512 KB (Kilobyte)
B. 2 MB (Megabyte)
C. 4 MB (Megabyte)
D. 1 MB (Megabyte)

22 Suppose the WREG register contains 0xFF and the instruction ADDLW 0x01 is executed. Which of the following flags in the STATUS register will be set as a result?

Status Register Medium
A. Z (Zero), C (Carry), DC (Digit Carry)
B. C (Carry), OV (Overflow)
C. Z (Zero), N (Negative)
D. N (Negative), Z (Zero)

23 A PIC18F458 is operating with a 20 MHz crystal oscillator (Fosc). What is the time required to execute a single-cycle instruction like NOP?

Introduction to PIC8F458 Medium
A. 200 ns
B. 50 ns
C. 100 ns
D. 20 ns

24 If you are designing a battery-powered device and want it to reset automatically if the voltage drops to a critical level (e.g., 2.5V), which configuration setting should you enable?

PIC configuration register Medium
A. Watchdog Timer (WDT)
B. Power-up Timer (PWRT)
C. Low-Voltage Programming (LVP)
D. Brown-out Reset (BOR)

25 To access a data register at the address 0x3A5 in a PIC18's data RAM, what value must be loaded into the Bank Select Register (BSR) before using a direct addressing instruction?

File register Medium
A. 0x3A
B. 0x03
C. 0x05
D. 0x0A

26 Analyze the following PIC18 assembly code. What will be the final value in the WREG register?

MOVLW 0x55
XORLW 0xFF
ADDLW 0x01

PIC WREG register Medium
A. 0xAC
B. 0xAB
C. 0x56
D. 0xAA

27 What is the primary advantage of the Harvard architecture, as implemented in PIC microcontrollers, for real-time embedded systems?

PIC architecture Medium
A. It uses a single shared bus for both data and instructions, simplifying PCB design.
B. It allows the CPU to fetch an instruction and access data memory at the same time, increasing throughput.
C. It simplifies the instruction set by removing data-specific commands.
D. It requires less memory to store a program compared to a Von Neumann architecture.

28 When a CALL instruction is executed at program address 0x01A0 in a PIC18, what value is pushed onto the top of the stack?

Program counter and program ROM space in PIC Medium
A. 0x01A2
B. The address of the subroutine.
C. 0x01A4
D. 0x01A0

29 A key feature of the PIC18F458 is its integrated ECAN module. What primary application is this module designed for?

Introduction to PIC8F458 Medium
A. Robust networking in automotive and industrial environments.
B. High-speed serial communication with PCs (like USB).
C. Interfacing with SD cards and other storage media.
D. Wireless communication like Wi-Fi or Bluetooth.

30 The instruction BTFSC STATUS, Z is located at address 0x100. The next instruction, GOTO L1, is at 0x102. If the Zero (Z) flag is set to 1 just before the BTFSC instruction is executed, what will happen?

Status Register Medium
A. The program will execute the GOTO L1 instruction.
B. The microcontroller will reset.
C. The GOTO L1 instruction will be skipped.
D. The Z flag will be cleared.

31 What is the primary purpose of setting the Code Protection (CP) bits in the PIC18's configuration registers?

PIC configuration register Medium
A. To prevent the program code from being read out of the device by an external programmer.
B. To protect the data RAM from being corrupted by power surges.
C. To encrypt the data being sent over communication peripherals.
D. To prevent the program from accidentally overwriting itself during runtime.

32 Which characteristic of the PIC microcontroller family's instruction set architecture (ISA) leads to highly predictable instruction timing?

Introduction to PIC microcontrollers Medium
A. The use of microcode for instruction execution.
B. A small set of optimized, fixed-length instructions (RISC).
C. A large number of complex instructions (CISC).
D. A variable clock speed that adjusts to the instruction being executed.

33 Consider the instruction SUBWF REG1, F. If REG1 initially contains 0x10 and WREG contains 0x05, what are the final contents of REG1 and WREG after the instruction executes?

PIC WREG register Medium
A. REG1 = 0x0B, WREG = 0x05
B. REG1 = 0x05, WREG = 0x05
C. REG1 = 0x10, WREG = 0x0B
D. REG1 = 0x0B, WREG = 0x0B

34 In the PIC18 architecture, the first 96 bytes of Bank 0 and the last 160 bytes of Bank 15 are part of the 'Access RAM'. What is the primary advantage of placing a variable in the Access RAM?

File register Medium
A. It provides more storage space than standard General Purpose Registers (GPRs).
B. It can be accessed faster than any other RAM location, regardless of the current Bank Select Register (BSR) value.
C. Variables in Access RAM are protected from being overwritten.
D. It is the only part of RAM that is non-volatile.

35 What is the function of the Bank Select Register (BSR) in the PIC18 architecture?

PIC architecture Medium
A. To hold the upper address bits for accessing the full range of data memory (File Registers).
B. To switch the CPU between active mode and sleep mode.
C. To choose between program memory and data memory for the next operation.
D. To select which of the 32 interrupt vectors is currently active.

36 An unconditional branch instruction, BRA MyLabel, is used in a PIC18 program. This instruction uses relative addressing. If the BRA instruction is at address 0x200 and MyLabel is at address 0x180, what is the 11-bit signed offset encoded within the BRA instruction?

Program counter and program ROM space in PIC Medium
A. -64
B. +128
C. -130
D. -128

37 After performing the subtraction 0x7F - 0x80 using a SUBWF instruction on a PIC18, the result in the destination register is 0xFF. Which status flags would be set?

Status Register Medium
A. MyVar becomes 0xFF, and the N (Negative) flag is set.
B. MyVar becomes 0x01, and no flags are affected.
C. MyVar becomes 0xFF, and the Z (Zero) flag is set.
D. MyVar becomes -1, and the C (Carry) flag is set.

38 If you need to measure the duration of an external pulse with high precision on a PIC18F458, which peripheral would be most suitable for the task?

Introduction to PIC8F458 Medium
A. The internal EEPROM data memory.
B. A general-purpose I/O pin configured as an interrupt.
C. The Analog-to-Digital Converter (ADC).
D. The CCP (Capture/Compare/PWM) module in Capture mode.

39 In the context of the PIC18's two-stage instruction pipeline, what happens when a GOTO instruction is executed?

PIC architecture Medium
A. The pipeline executes both the instruction after the GOTO and the instruction at the destination address simultaneously.
B. The pipeline stalls for two cycles to allow the new address to be calculated and loaded.
C. The instruction that was fetched during the GOTO's execute cycle is discarded (flushed), and a new fetch begins from the branch address.
D. The pipeline continues without interruption, as the GOTO is executed in a single cycle.

40 A PIC18F device has 1536 bytes of data RAM. How many distinct 256-byte banks are available for general-purpose use?

File register Medium
A. 16 banks
B. 8 banks
C. 4 banks
D. 6 banks

41 A PIC18 microcontroller with a 21-bit Program Counter (PC) executes a CALL instruction located at program memory address 0x00FFFF. The target of the CALL is 0x010004. What value is pushed onto the hardware stack?

Program counter and program ROM space in PIC Hard
A. 0x010001
B. 0x010000
C. 0x010002
D. 0x00FFFF

42 Consider the following PIC18 assembly instructions executed sequentially:

assembly
MOVLW 0x7F
ADDLW 0x01


After these instructions, what will be the state of the Negative (N), Overflow (OV), and Carry (C) flags in the STATUS register?

Status Register Hard
A. N=1, OV=0, C=1
B. N=0, OV=1, C=0
C. N=0, OV=0, C=1
D. N=1, OV=1, C=0

43 A PIC18 is configured with high-priority interrupts enabled. The main loop sets the BSR to 0x05 and STATUS to 0x18. A high-priority interrupt occurs. The ISR does not modify the BSR or STATUS registers. After the ISR finishes with a RETFIE FAST instruction, what are the values of BSR and STATUS upon returning to the main loop?

File register Hard
A. BSR = 0x05, STATUS = 0x18
B. BSR = 0x00, STATUS = 0x00
C. BSR and STATUS values are unpredictable.
D. BSR = 0x0F, STATUS = 0x00

44 A PIC18F458 is configured with Brown-out Reset (BOR) enabled at 2.7V and the Watchdog Timer (WDT) enabled. The device enters sleep mode. While in sleep, the Vdd drops to 2.5V, and shortly after, the WDT times out. Upon reset, which bit(s) in the RCON register will indicate the cause of the reset?

PIC configuration register Hard
A. Only the !WDTO bit will be cleared.
B. Only the !BOR bit will be cleared.
C. Only the !POR bit will be cleared.
D. Both !WDTO and !BOR bits will be cleared.

45 Analyze the following PIC18 code snippet in terms of execution cycles, assuming a BRA instruction takes 2 cycles. How many cycles does it take from the start of the BRA instruction to the completion of the ADDLW instruction?

assembly
BRA Target
NOP
DECF COUNTER, F
Target: ADDLW 0x10

PIC architecture Hard
A. 3 cycles
B. 2 cycles
C. 4 cycles
D. 5 cycles

46 What is the final value in the WREG register after the following sequence of PIC18 instructions is executed?

assembly
MOVLW 0x08
MOVWF MY_REG
SUBLW 0x02 ; W = 0x02 - W
ADDWF MY_REG, W ; W = W + MY_REG

WREG register Hard
A. 0x06
B. 0x02
C. 0xFA
D. 0x0E

47 A PIC18F458 application requires switching the MSSP module from SPI Master mode to I2C Master mode on the same pins (RC3/SCK/SCL and RC4/SDI/SDA). Which of the following statements most accurately describes the critical register reconfiguration needed to prevent bus conflicts?

Introduction to PIC8F458 Hard
A. Set the SSPEN bit to 0, set TRIS bits for I2C, clear the SPIBF flag in SSPSTAT, reconfigure SSPCON1, then set SSPEN to 1.
B. Set the SSPEN bit to 0, reconfigure SSPCON1 and SSPSTAT, set the TRIS bits for I2C (SCL/SDA as inputs), then set SSPEN to 1.
C. The MSSP module must be fully reset by clearing the RCON register before changing modes.
D. Simply change the SSPM bits in SSPCON1 from an SPI mode to an I2C mode; the hardware handles the pin states automatically.

48 A PIC18 device has a 31-level hardware return address stack. A recursive function is called 32 times without returning. What happens when the 32nd RETURN instruction is executed?

Program counter and program ROM space in PIC Hard
A. The microcontroller resets due to a stack overflow error.
B. The program hangs, and the RETURN instruction is never completed.
C. The program returns to the address pushed by the second CALL instruction.
D. The program returns to the address pushed by the first CALL instruction.

49 An array of 16 bytes is located starting at address 0x120. A programmer wants to clear this array to zeros using indirect addressing with FSR0. Which code snippet correctly performs this operation?

assembly
; Snippet A
MOVLW 0x12
MOVWF FSR0H
MOVLW 0x20
MOVWF FSR0L
MOVLW 16
Loop:
CLRF POSTINC0
DECFSZ WREG, W
BRA Loop

; Snippet B
LFSR 0, 0x120
MOVLW 16
MOVWF COUNTER
Loop:
CLRF INDF0
INCF FSR0L, F
DECFSZ COUNTER, F
BRA Loop

File register Hard
A. Both snippets will fail because they do not handle FSR0H rollovers.
B. Snippet A is correct, but Snippet B has a bug.
C. Both Snippet A and Snippet B correctly clear the array.
D. Snippet B is correct, but Snippet A will corrupt memory.

50 What is the final value in WREG and the state of the Carry (C) flag after the following PIC18 assembly code, designed for BCD arithmetic, is executed?

assembly
MOVLW 0x38 ; Load BCD 38
ADDLW 0x49 ; Add BCD 49
DAW ; Decimal Adjust WREG

Status Register Hard
A. WREG = 0x27, C = 1
B. WREG = 0x81, C = 0
C. WREG = 0x87, C = 1
D. WREG = 0x87, C = 0

51 A bootloader resides in the boot block of a PIC18. The application code is in block 0. Which configuration bit setting would allow the bootloader to erase and write to block 0, but prevent it from reading the contents of block 0 using table read instructions?

PIC configuration register Hard
A. WRT0=1 (Write Protect enabled), EBTR0=1 (Table Read Protect disabled)
B. WRT0=0 (Write Protect disabled), CP0=0 (Code Protect disabled)
C. WRT0=1 (Write Protect enabled), CP0=0 (Code Protect disabled)
D. WRT0=0 (Write Protect disabled), EBTR0=0 (Table Read Protect enabled)

52 A PIC18 performs a signed multiplication: MOVLW 0xFE; MOVWF REG_A; MOVLW 0x04; MULWF REG_A. After the MULWF instruction, what are the values in the PRODH:PRODL register pair and the state of the Negative (N) and Overflow (OV) flags in the STATUS register?

PIC architecture Hard
A. PRODH:PRODL = 0x07F8, N=0, OV=1
B. PRODH:PRODL = 0xFFF8, N=1, OV=0
C. PRODH:PRODL = 0x00F8, N=0, OV=0
D. PRODH:PRODL = 0xFFF8, N=1, OV=1

53 Which instruction sequence best demonstrates the fundamental advantage of the PIC18's Modified Harvard architecture over a pure Von Neumann architecture?

Introduction to PIC microcontrollers Hard
A. TBLPTRU=0x01; TBLPTRH=0x80; TBLPTRL=0x00; TBLRD*+
B. MOVLW 0x55; MOVWF PORTB
C. LFSR 1, 0x100; MOVF INDF1, W
D. ADDWF REG1, F; BTFSC STATUS, C

54 Given REG_A = 0x80 and WREG = 0x80. The instruction CPFSLT REG_A is executed. What is the immediate outcome?

Status Register Hard
A. The next instruction is skipped because 0x80 is treated as negative and thus less than 0x80.
B. The next instruction is executed because the instruction performs an unsigned compare.
C. The next instruction is skipped because the values are equal.
D. The STATUS register's Z flag is set and the next instruction is executed.

55 A PIC18 MCU has a variable MY_VAR located in the Access RAM at address 0x40. A subroutine is called which sets the Bank Select Register (BSR) to 4. Inside this subroutine, the instruction INCF 0x40, F is executed. Which memory location is actually incremented?

File register Hard
A. Address 0x040 in Bank 0.
B. Address 0x440 (Bank 4, offset 0x40).
C. The instruction is invalid as 0x40 is out of range for direct addressing with BSR=4.
D. Address 0x40 in the Access RAM.

56 A PIC18F458 is running from its internal oscillator block (INTOSC) at 8 MHz. The 4x PLL is enabled in the configuration bits, creating a system clock () of 32 MHz. Timer1 is configured with a 1:8 prescaler and is clocked from . What 16-bit value must be loaded into TMR1H:TMR1L to generate an interrupt every 20ms?

PIC18F458 Hard
A. 0x63C0
B. 0x0000
C. 0xB1E0
D. 0xFFFF - 20000

57 A program needs to jump from address 0x1000 to 0x3200. Which of BRA (Branch) or GOTO (Go To) is the most efficient choice and why?

Program counter and program ROM space in PIC Hard
A. BRA is more efficient because it is a single-word instruction.
B. GOTO must be used because the jump distance is beyond the range of BRA.
C. Both are equally efficient as they take the same number of cycles.
D. BRA is more efficient because it uses relative addressing which is faster.

58 What is the primary architectural reason that most PIC18 instructions complete in a single instruction cycle, even though they involve multiple steps like fetch, decode, and execute?

PIC architecture Hard
A. A large number of general-purpose file registers.
B. A very high oscillator frequency.
C. Instruction pipelining.
D. The use of a hardware stack.

59 Consider the code BCF STATUS, C followed by RLCF MY_REG, F. If MY_REG initially holds the value 0xB5 (binary 10110101), what will its value be after this sequence?

WREG register Hard
A. 0x6B
B. 0xB5
C. 0xD5
D. 0x6A

60 To operate a PIC18F458 with the highest possible performance using an external 10 MHz crystal, what is the correct setting for the FOSC<3:0> bits in the CONFIG1H register?

PIC configuration register Hard
A. EC (External Clock)
B. HSPLL (HS Oscillator, PLL Enabled)
C. INTIO2 (Internal Oscillator, RA6/RA7 are I/O)
D. HS (High-Speed Crystal/Resonator)