GPIO

GPIO (General Purpose Input/Output)

How does tagging bit 28 of address 0x2009 C020 turn the LED on and off in the lab for ECE 222?

Info

Peripherals (I/O devices and timers) have interface registers mapped to addresses not used by Memory#memory

Example

Lab microcontrollers:

GPIO port 1 connects to 32 I/O Pins, and pins 28, 29, and 31 are connected to LEDs.

Port 1 has registers at addresses:

  • 0x2009 C020 (FIODIR, fast input/output directory)
  • 0x2009 C030 (FIOMASK)
  • 0x2009 C034 (FIOPIN)
  • 0x2009 C038 (FIOSET)
  • 0x2009 C03C (FIOCLR)

To toggle bit 28 of GPIO port 1:

MOV32 R0, #0x2009C020 ; LDR R0, #0x2009C020
LDR R1, [R0]
EOR R1, #1 << 28 ; Toggle 28th bit
STR R1, [R0]