Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////
- /*RAM test*/
- /*This is a test code for RAM and GPIO.
- First it sets the leds to (0xaa) value.
- Then, it waits 25000*2000 = 50000000 cycle (~7s) on this state.
- After that, it sets the leds to (0x0f) value.
- Then, it writes 0 to base_adress of RAM and 4 to base_adres+4 of RAM...
- it writes to RAM until base_adres+32000.
- when the writing process is fnished, it starts to read the same values
- by using the same method like in writting process and check if [0]=0, if [4]=4 ....
- if there is an error it increases the error counter (r19) and
- writes how many errors is made to gpio (leds).
- If there is not an error it goes to noerror tag and writes 129 to gpio (leds).
- Then the code goes in an infinite loop.*/
- #include "board.h"
- #define GPIO_BASE GPIO0_BASE
- boot_init:
- l.movhi r0, 0
- l.ori r15, r0, 0xff
- l.movhi r16, hi(GPIO_BASE)
- l.sb 0x1(r16), r15 // set the direction reg to output!
- //l.sb 0x4(r16), r15 //for testing orpsoc-v2
- //l.sb 0x5(r16), r15 //for testing orpsoc-v2
- l.ori r14, r0, 0xaa
- l.sb 0x0(r16), r14 // write the value to the leds!
- l.and r22, r0, r0
- l.and r21, r0, r0
- delay:
- l.addi r21, r21, 1
- l.sfeqi r21, 25000 // set the flag if r21 == 25000
- l.bnf delay // if the flag is not set go to delay
- l.nop
- l.bf loop0 // if the flag set go to loop0
- l.nop
- loop0:
- l.addi r22, r22, 1
- l.sfeqi r22, 2000 // set the flag if r21 == 2000
- l.and r21, r0, r0
- l.bnf delay
- l.nop
- l.ori r14, r0, 0x0f
- l.sb 0x0(r16), r14 // write the value to the leds!
- l.and r21, r0, r0
- l.and r19, r0, r0 // make r19 zero
- l.and r17, r0, r0 // make r17 zero
- loop1:
- l.sw 0x0(r17), r17 // store the value of r17 to the adress pointed by r17
- l.addi r17, r17, 4 // increase content of r17 by 4
- l.sfeqi r17, 32000 // set flag if r17 == 10000
- l.bnf loop1 // if flag is not set go to loop1
- l.ori r14, r0, 0x03
- l.sb 0x0(r16), r14
- l.and r17, r0, r0 // make r17 zero
- loop2:
- l.sfeqi r17, 32000 // set flag if r17 == 10000
- l.bf finish // if flag is set go to bitti
- l.nop
- l.lws r18, 0x0(r17) // load content of the adress pointed by r17 to r18
- l.sfeq r17, r18 // set flag if r17=r18
- l.addi r17, r17, 4 // increase r17 by 1
- l.bf loop2
- l.nop
- l.bnf error
- l.nop
- error:
- l.addi r19, r19, 1 // increase r19 by 1
- l.j loop2
- l.nop
- finish:
- l.sb 0x0(r16), r19 // // write the value to the leds!
- l.sfeqi r19, 0 //set flag if r19 == 0
- l.bf noerror // go to noerror
- l.nop
- l.bnf ledset // go to ledset
- l.nop
- noerror:
- l.and r20, r0, r0 //make r20 zero
- l.ori r20, r0, 129 //store 120 in r20
- l.sb 0x0(r16), r20 //store byte value in r20 to r16
- ledset:
- l.nop /* wait on this state */
- l.j ledset
- l.nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement