Embedded Systems & Firmware

When using a microcontroller GPIO (general-purpose input/output) pin, what must be configured first?

  1. AWhether the pin is used as an input or an output (its direction)
  2. BThe color of the pin
  3. CThe name of the programmer who wrote the code
Show answer and explanation

Answer: A. Whether the pin is used as an input or an output (its direction)

A GPIO pin can be used as either an input or an output under software control. Configured as an output through the direction register, the value written to the output register becomes the pin voltage; configured as an input, the pin voltage can be read from the input register. Most microcontrollers also let you set pull-ups, the output type (push-pull or open-drain) and whether the pin serves another peripheral.

  • A. Correct. It is set in a direction register.
  • B. Pin color is irrelevant.
  • C. The programmer's name is irrelevant.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. What is the phenomenon called in which a mechanical switch's contacts bounce, turning on and off many times in a short period when pressed?
  2. Which is the most suitable way to remove switch bounce in software?
  3. 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?
  4. 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?
  5. Which method is commonly used by microcontrollers to adjust LED brightness or motor speed?