Pushbuttons on DE1-SoC Computer

Synchronization between HW/SW

Edge capture register goes to 1 and stays there after release

Edge capture register goes to 1 and stays there after release

Untitled

Example: KEY push buttons with Data Register

Example: KEY push buttons with Edge Capture Register

	_start: 
    movia r8,KEY_BASE ; set r8 to base KEY port
    movia r9,LEDs ; set r9 to base of LEDR port
    movi r10, 1 ; first value of LEDR output is 1

poll: 
    ldwio r11, 0xC(r8) ; load edge capture reg
    andi r11,r11,0x4 ; 'select' bit for Key2 is 0100
    beq r11, r0, poll ; if 0, nothing changed -> loop

    stwio r10, (r9) ; turn on/off LED
    xori r10,r10, 1 ; invert r10 for next time

    movi r12, 0x4 ; turn off edge capture bit
    stwio r12, 0xC(r8) ; by writing 1 into bit 2
    ; that takes a lot of getting use to!

    br poll ; go back to poll loop

Hardware Timers

Timer Port Registers in Nios II “interval timer”

Memory Mapped Address Register Notes
0xff202000 Status Register Bit 0 = TO (Time Out)
Bit 1 = RUN
0xff202004 Control Register Bit 0 = ITO
Bit 1 = CONT
Bit 2: START
Bit 3: STOP
0xff202008 Start Register Bits 0-15: Counter start (low order)
0xff20200c Bits 16 - 31: Counter start (high order)

Untitled

Status Register: contains status flags