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: Write 0x000000001 to the 7-segment displays

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

  movia r2,ADDR_7SEG1
  movia r3,0x00000006   # bits 0000110 will activate segments 1 and 2 
  stwio r3,0(r2)        # Write to 7-seg display 
  movia r2,ADDR_7SEG2
  stwio r0, 0(r2) 

C Example: Write 0x000000001 to the 7-segment displays

#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;
}