Embedded Systems & Firmware

A timer counts a 16 MHz clock divided by 16 with a prescaler and raises an interrupt every 1000 counts. What is the interrupt interval?

  1. A1 µs
  2. B1 ms
  3. C16 ms
Show answer and explanation

Answer: B. 1 ms

Dividing 16 MHz by 16 gives a 1 MHz timer clock, so one count is 1 µs. An interrupt every 1000 counts gives an interval of 1 µs × 1000 = 1 ms. A prescaler divides a clock that is too fast so the timer can count over a useful range. A 1 ms interrupt is commonly used for timekeeping, reading switches and the RTOS tick.

  • A. 1 µs is the time of a single count.
  • B. Correct. 1 µs × 1000 = 1 ms.
  • C. The prescaler divides by 16 rather than multiplying.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. 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?
  2. Which method is commonly used by microcontrollers to adjust LED brightness or motor speed?
  3. What is the input capture function of a microcontroller timer used for?
  4. What should be avoided inside an interrupt handler?
  5. 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?