Embedded System Tutorial GPIO

From Embedded Systems Learning Academy
Revision as of 21:49, 19 July 2013 by Preet (talk | contribs) (Created page with "== Objective == Interface your LPC17xx to a switch and an LED. Although the interface may seem simple, you do need to consider hardware design and know some of the fundamenta...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Objective

Interface your LPC17xx to a switch and an LED.

Although the interface may seem simple, you do need to consider hardware design and know some of the fundamental of electricity. There are a couple of goals for us :

  • No hardware damage if faulty software is written.
  • Circuit should prevent excess amount of current to avoid processor damage.

Required Background

  • You should know how to bit-mask variables
  • You should know how to wire-wrap
  • You should know fundamentals of electricity and the famous V = IR equation.

Lecture

Hardware Registers

The hardware registers map to physical pins. If we want to attach our switch and the LED to our microcontroller's PORT0, then here are the relevant registers and their functionality :

LPC17xx Port0 Registers
LPC_GPIO0->FIODIR Direction of the port pins, 1 = output
LPC_GPIO0->FIOPIN
Read : Sensed inputs of the port pins, 1 = HIGH
Write : Control voltage level of the pin, 1 = 3.3v
LPC_GPIO0->FIOSET Write only : Any bits written 1 are OR'd with FIOPIN
LPC_GPIO0->FIOCLR Write only : Any bits written 1 are AND'd with FIOPIN

Switch Design

LED Design

Conclusion

At the end of this lab, you should be familiar with how a microcontroller's memory can access physical pins.