Seven-segment Display

The seven-segment displays are configured as two 32-bit registers. Each byte of each register directly controls the segments of the corresponding displays, turning them on and off. Thus, it is necessary to provide some decoding to display hexadecimal values on the displays. A 1 is used to turn on a segment; 0 turns it off.

Device7-segment Display
ConfigurationTwo 32-bit registers
Input/OutputOutput only
Address BaseHEX3 to HEX0: 0xFF200020, HEX5 to HEX4: 0xFF200030
Address Map 0xFF00020:
  • Bits 6 to 0: HEX06-0
  • Bits 14 to 8: HEX16-0
  • Bits 22 to 16: HEX26-0
  • Bits 30 to 24: HEX36-0
0x10000030:
  • Bits 6 to 0: HEX46-0
  • Bits 14 to 8: HEX56-0
  • Bits 22 to 16: Unused
  • Bits 30 to 24: Unused
Diagram taken from Altera DE1-SoC Computer manual

Assembly Example: Lights up segments 1 and 2 on the 7-segment display of HEX0

  .equ ADDR_7SEG1, 0xFF200020
  .equ ADDR_7SEG2, 0xFF200030

  ldr r0, =ADDR_7SEG1
  ldr r1, =#0b0000110   	// bits 0b0000110 will activate segments 1 and 2 
  str r1, [r0]                  // Write to 7-seg display 
  ldr r0, =ADDR_7SEG2
  ldr r1, =#0
  str r1, [r0] 

C Example: Lights up segments 1 and 2 on the 7-segment display of HEX0

#define ADDR_7SEG1 ((volatile long *) 0xFF200020)
#define ADDR_7SEG2 ((volatile long *) 0xFF200030)

int main()
{
   # bits 0000110 will activate segments 1 and 2 
   *ADDR_7SEG1 = 0x00000006; 
   *ADDR_7SEG2 = 0;
}