Embedded Systems & Firmware

A PWM signal has a period of 1000 counts, with the output high (1) for 250 counts of each period. What is the duty cycle?

  1. A75%
  2. B25%
  3. C250%
Show answer and explanation

Answer: B. 25%

The duty cycle is the fraction of each period during which the output is high: 250 ÷ 1000 = 25%. PWM (pulse-width modulation) adjusts average voltage or power by changing the high time while keeping the period constant. A microcontroller timer switches the output by comparing its counter with a compare value, so it can produce PWM continuously without CPU involvement.

  • A. 75% is the fraction of time the output is low.
  • B. Correct. 250 ÷ 1000 = 0.25.
  • C. A fraction cannot exceed 100%.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. Which method is commonly used by microcontrollers to adjust LED brightness or motor speed?
  2. What is the input capture function of a microcontroller timer used for?
  3. What should be avoided inside an interrupt handler?
  4. When the program above is compiled with optimization, led_on() may never be called even after the timer interrupt fires. Which pairs the cause with the fix correctly?
  5. On an 8-bit microcontroller, a timer interrupt increments the 32-bit variable ticks, and the main code reads ticks to compute elapsed time. Why is a wildly wrong value occasionally read?