Professional Documents
Culture Documents
Quiz3 Answers
Quiz3 Answers
Name: _____________________________
Student ID: _____________________________
1. A microcontroller PWM signal is used to drive the MOSFET of a buck (step-down) power converter. The
PWM period is 255us with 255 PWM steps.
At 5V output voltage, the PWM on-time is 100us and the PWM off-time is 155us. (6 points)
What is the MOSFET switching frequency (in Hz)? 1/(255us) = 3.92kHz (1 pt)
______________________________________
What is the duty cycle at 2.5V (in %)? 39.2% x 2.5V/(5V) = 19.6% (2 pt)
______________________________________
What is the maximum output voltage (in V)? 5V x 255 / 100 = 12.75V (2 pt)
______________________________________
2. Which of the following statements related to Asynchronous Communication are True (T)? (4 points)
• Asynchronous Communication is always faster than Synchronous Communication. T / F
• Asynchronous Communication is always slower than Synchronous Communication. T / F
• Modern DRAM (DDR4) uses Asynchronous Communication. T/F
• UART uses Asynchronous Communication. T/F
3. In a Cortex-M4 embedded system, an EXC_RETURN value (e.g. 0xFFFFFFF9) is loaded into the link
register (R14) during an interrupt service routine (ISR). Check if the following statements are True (T) or
False (F). (4 points)
• EXC_RETURN specifies if the interrupted routine is using the main stack pointer. T/F
• The loading of EXC_RETURN to R14 is done is software. T/F
• The ISR must check the EXC_RETURN value in software. T/F
• The original R14 value is saved before EXC_RETURN value is loaded. T/F
4. In a Cortex-M4 embedded system, a certain hardware interrupt may be disabled by using either
NVIC_DisableIRQ(IRQ_num) or __disable_irq() CMSIS API?
What are the differences between these two CMSIS API? (4 points)
The first API disables a specific maskable interrupts, meaning that other maskable
_______________________________________________________________________________________
interrupts may still be active.
_______________________________________________________________________________________
The second API disables all maskable interrupts.
_______________________________________________________________________________________
_______________________________________________________________________________________
Page 1 of 6
EE3220 Class Quiz #3 (Closed Book) Time Limit = 60 minutes Revision 1.0
5. In an ARM SOC, the same reset vector is used for cold boot (power-on reset) and warm boot (pushing reset
button). Check if the following statements are True (T) or False (F). (4 points)
• Among all interrupts, the reset interrupt has the highest priority. T/F
• The software cannot distinguish between cold boot and warm boot. T/F
6. The C programming language is used in many embedded systems. Check if the following statements are
True (T) or False (F). (4 points)
Check if any library files are needed and include them. Assign physical addresses in
_______________________________________________________________________________________
object codes. Cross reference all object files. Check for any missing references. Check
_______________________________________________________________________________________
for any memory issue. Create a single linked file.
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
8. In an embedded system, a certain C program may occasionally crash. There is an integer array (with 512
elements) declared inside the main() function. The problem goes away if the array is declared as “static”
instead of “auto”. Give a possible explanation. Separately, the same integer array may be implemented
using “malloc”. Explain if this is a good idea. (6 points)
Declaring an array within main function or outside main function should not make any
_______________________________________________________________________________________
difference unless the stack segment runs out of space.
_______________________________________________________________________________________
The stack segment size might be too small.
_______________________________________________________________________________________
As stack and heap usually share the same memory space, the suggested solution is
_______________________________________________________________________________________
ineffective.
_______________________________________________________________________________________
_______________________________________________________________________________________
Page 2 of 6
EE3220 Class Quiz #3 (Closed Book) Time Limit = 60 minutes Revision 1.0
9. Assume a Cortex-M4 processor is running in Thread Mode with its register and stack values listed in Table 9.1.
An interrupt occurs, which prompts the processor to save its registers (R0, R1, R2, R3, R12, LR, PC, xPSR) to its
stack. Assume the interrupt vector is located at 0x0000B000 and the EXC_RETURN value is 0xFFFFFFFD.
Write the new register and stack values in the beginning of the interrupt service routine. Hints: a lower register is
stored to a lower stack address and a higher register is stored to a higher stack address. (16 points)
Page 3 of 6
EE3220 Class Quiz #3 (Closed Book) Time Limit = 60 minutes Revision 1.0
10. A “critical section” is often used in an embedded system. Explain when and why a “critical section” is used.
Describe the potential issues when there are too many “critical sections.”
_______________________________________________________________________________________
Critical section is used to support atomic operation, avoiding race conditions
and potential data inconsistency among multiple threads. (4 points)
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
Two different students implement two different “critical sections” (Implementation 1 and Implementation 2).
Implementation 1 Implementation 2
Implementation 1 is preferred.
_______________________________________________________________________________________
Implementation 2 may inadvertently enable interrupts.
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
Page 4 of 6
EE3220 Class Quiz #3 (Closed Book) Time Limit = 60 minutes Revision 1.0
11. Convert the following “factorial” assembly function to an equivalent “factorial” C function. How many bytes are
pushed onto stack in each recursive function call. How many bytes are pushed o stack when factorial(100)
is called. Explain why recursive functions are seldom used in an embedded system. (16 points)
It is difficult to design a proper stack size, and difficult to debug any related bug.
Page 5 of 6
EE3220 Class Quiz #3 (Closed Book) Time Limit = 60 minutes Revision 1.0
12. The “RBIT” instruction is used to reverse the bits in a word, and the “REV” instruction is used to reverse the byte
order in a word. What are the applications of these two instructions? (6 points)
Data communication with another system with a different endianness (e.g. Internet).
_______________________________________________________________________________________
RBIT can be used for bit data transmission (like UART). REV can be used for byte data
_______________________________________________________________________________________
transmission (like Internet).
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
What are the values of R0, R1, R2 after the following operations? Show your work. (10 points)
R0: 0x43215678
_______________________________________________________________________________________
R1: 0x1E6A8432
_______________________________________________________________________________________
_______________________________________________________________________________________
R2: 0x32846A1E
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
Page 6 of 6