Embedded Systems & Firmware

What is the input capture function of a microcontroller timer used for?

  1. ATo capture and save a screen image
  2. BTo record the counter value at the instant an input signal changes, precisely measuring pulse width or frequency
  3. CTo output a PWM signal from a pin
Show answer and explanation

Answer: B. To record the counter value at the instant an input signal changes, precisely measuring pulse width or frequency

With input capture, hardware copies the timer counter into a register at the instant the input signal rises or falls. The difference between two captured values gives the pulse width or period. Reading the time in software after an interrupt adds error from processing delays, but this method measures precisely regardless of them. It is used with rotation sensors, ultrasonic rangefinders and the like.

  • A. It has nothing to do with images.
  • B. Correct. Hardware records the value at that instant.
  • C. PWM output is done by output compare and similar functions.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. What should be avoided inside an interrupt handler?
  2. 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?
  3. 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?
  4. What is a characteristic of serial communication with a UART?
  5. On a 115200 bps UART using 8 data bits, no parity and 1 stop bit (8N1), roughly how many bytes can be sent per second?