displays only the 8 leds

Discussion in 'The Projects Forum' started by NAFISA22, Mar 22, 2016.

  1. NAFISA22

    Thread Starter New Member

    Mar 22, 2016
    2
    0
    this is a code that displays 1 led after 3 secs 4 leds then 8 leds.the problem us that it displays only the 8 leds.i changed the delay but nothing.please help
    .data
    .equ TIMER_BASE, 0x10002000
    .equ PERIOD, 0x1111ffff
    .equ DELAY, 20ns
    .equ LED, 0x10000010

    .text
    .global _start
    _start:


    movia r4, TIMER_BASE
    movi r5, 6
    movia r2, PERIOD #load initial timer values
    stwio r2, 8(r4)
    srli r2, r2, 16
    stwio r2, 12(r4)
    stwio r5, 4(r4) #start the timer
    movi r6, DELAY #delay


    oneLED:
    movi r14, 0b10000000 #turn on One LED
    movia r15, LED
    stw r14, 0(r15)
    br fourLED

    ##############

    DELAY:
    subi r6,r6,1 #subtract 1 from delay
    bne r6,r0, DELAY #continue subtracting if delay not elapsed
    br DELAY #delay elapsed, redo the LOOP

    ##############

    fourLED:
    movi r14, 0b11110000 #turn on Four LEDs
    movia r15, LED
    stw r14, 0(r15)
    br eightLED

    eightLED:
    movi r14, 0b11111111 #turn on Eight LEDs
    movia r15, LED
    stw r14, 0(r15)
    br oneLED
     
  2. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,440
    368
    What happens if you disable or skip the section of code that turns on the 8 LEDs, do you just see 4 LEDs on?

    I haven't analysed your code but I suspect there is a problem with the delay routine and the code is cycling through so fast that it appears that 8 LEDs are on all the time.
     
    Last edited: Mar 22, 2016
  3. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,999
    745
    What language is this, looks similar to Asm?
     
  4. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,440
    368
    I think it's for the NIOS II
     
  5. NAFISA22

    Thread Starter New Member

    Mar 22, 2016
    2
    0
    when i removed the eight leds ,it didnt display anything so i tried changing the delay but nothing
     
  6. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,440
    368
    Did you also modify the code so that it doesn't try to jump to the 8 LED code. i.e.

    fourLED:
    movi r14, 0b11110000 #turn on Four LEDs
    movia r15, LED
    stw r14, 0(r15)
    br oneLED
     
Loading...