Advertisement
latifakcay

orpsocv3_ramtest

Oct 31st, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. ///////////
  2. /*RAM test*/
  3. /*This is a test code for RAM and GPIO.
  4. First it sets the leds to (0xaa) value.
  5. Then, it waits 25000*2000 = 50000000 cycle (~7s) on this state.
  6. After that, it sets the leds to (0x0f) value.
  7. Then, it writes 0 to base_adress of RAM and 4 to base_adres+4 of RAM...
  8. it writes to RAM until base_adres+32000.
  9. when the writing process is fnished, it starts to read the same values
  10. by using the same method like in writting process and check if [0]=0, if [4]=4 ....
  11. if there is an error it increases the error counter (r19) and
  12. writes how many errors is made to gpio (leds).
  13. If there is not an error it goes to noerror tag and writes 129 to gpio (leds).
  14. Then the code goes in an infinite loop.*/
  15. #include "board.h"
  16.  
  17. #define GPIO_BASE GPIO0_BASE
  18.  
  19. boot_init:
  20. l.movhi r0, 0
  21.  
  22. l.ori r15, r0, 0xff
  23. l.movhi r16, hi(GPIO_BASE)
  24. l.sb 0x1(r16), r15 // set the direction reg to output!
  25. //l.sb 0x4(r16), r15 //for testing orpsoc-v2
  26. //l.sb 0x5(r16), r15 //for testing orpsoc-v2
  27. l.ori r14, r0, 0xaa
  28. l.sb 0x0(r16), r14 // write the value to the leds!
  29.  
  30. l.and r22, r0, r0
  31. l.and r21, r0, r0
  32. delay:
  33. l.addi r21, r21, 1
  34. l.sfeqi r21, 25000 // set the flag if r21 == 25000
  35. l.bnf delay // if the flag is not set go to delay
  36. l.nop
  37. l.bf loop0 // if the flag set go to loop0
  38. l.nop
  39.  
  40. loop0:
  41. l.addi r22, r22, 1
  42. l.sfeqi r22, 2000 // set the flag if r21 == 2000
  43. l.and r21, r0, r0
  44. l.bnf delay
  45. l.nop
  46.  
  47. l.ori r14, r0, 0x0f
  48. l.sb 0x0(r16), r14 // write the value to the leds!
  49.  
  50. l.and r21, r0, r0
  51.  
  52.  
  53. l.and r19, r0, r0 // make r19 zero
  54. l.and r17, r0, r0 // make r17 zero
  55. loop1:
  56. l.sw 0x0(r17), r17 // store the value of r17 to the adress pointed by r17
  57. l.addi r17, r17, 4 // increase content of r17 by 4
  58. l.sfeqi r17, 32000 // set flag if r17 == 10000
  59. l.bnf loop1 // if flag is not set go to loop1
  60.  
  61. l.ori r14, r0, 0x03
  62. l.sb 0x0(r16), r14
  63.  
  64. l.and r17, r0, r0 // make r17 zero
  65. loop2:
  66. l.sfeqi r17, 32000 // set flag if r17 == 10000
  67. l.bf finish // if flag is set go to bitti
  68. l.nop
  69. l.lws r18, 0x0(r17) // load content of the adress pointed by r17 to r18
  70. l.sfeq r17, r18 // set flag if r17=r18
  71. l.addi r17, r17, 4 // increase r17 by 1
  72. l.bf loop2
  73. l.nop
  74. l.bnf error
  75. l.nop
  76.  
  77. error:
  78. l.addi r19, r19, 1 // increase r19 by 1
  79. l.j loop2
  80. l.nop
  81. finish:
  82. l.sb 0x0(r16), r19 // // write the value to the leds!
  83. l.sfeqi r19, 0 //set flag if r19 == 0
  84. l.bf noerror // go to noerror
  85. l.nop
  86. l.bnf ledset // go to ledset
  87. l.nop
  88.  
  89. noerror:
  90. l.and r20, r0, r0 //make r20 zero
  91. l.ori r20, r0, 129 //store 120 in r20
  92. l.sb 0x0(r16), r20 //store byte value in r20 to r16
  93.  
  94. ledset:
  95. l.nop /* wait on this state */
  96. l.j ledset
  97. l.nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement