Guest User

Untitled

a guest
Oct 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. .syntax unified
  2. .cpu cortex-m3
  3. .thumb
  4. .global sseglut
  5.  
  6. .equ GPIOA_IDR, 0x40010808
  7. .equ GPIOB_ODR, 0x40010C0C
  8.  
  9. sseglut:
  10.  
  11. ldr r7, =#0
  12.  
  13.  
  14. //beginning
  15. loop:
  16. // Read GPIOA_IDR
  17. ldr r6, =#1000000
  18. ldr r0, =GPIOA_IDR
  19. ldr r1, [r0]
  20.  
  21. // Extract bits required
  22. ubfx r2,r1, #0, #3 //or #3
  23.  
  24.  
  25. //after ubfx
  26. //if gpioa is high
  27. cmp r2, #0
  28. it ne //gpio is high
  29. bne bounceDelay //branch to bounce before performing action
  30.  
  31. //else branch back to beginning
  32. b loop
  33.  
  34. bounceDelay:
  35. subs r6, #1
  36.  
  37. cmp r6, #0
  38. it eq
  39. beq performAction
  40.  
  41. b bounceDelay
  42.  
  43.  
  44. performAction:
  45. //branch -perform action
  46. // Get data from LUT
  47. //ldr r8, =#10 //reset bounce delay
  48. ldr r3, =ssegdata
  49. ldrb r4, [r3,r7] //r7 is our counter
  50.  
  51. // Shift data to the correct bits
  52. lsl r5, r4, #3
  53.  
  54. // Write data to GPIOB_ODR
  55. ldr r6, =GPIOB_ODR
  56. str r5, [r6]
  57.  
  58.  
  59. // //if register contains the last number
  60. cmp r7, #7
  61. it eq
  62. beq resetr7 //set the register to 'C'
  63.  
  64. //else
  65. //increment a register and display the correct number
  66. add r7, #1
  67.  
  68. //branch to waiting branch
  69. b waitingBranch
  70.  
  71.  
  72. waitingBranch:
  73. //if gpio is still high, we need to stay in this branch until it goes low
  74. ldr r0, =GPIOA_IDR
  75. ldr r1, [r0]
  76.  
  77. // Extract bits required -input bits
  78. ubfx r2,r1, #0, #3 //or #3
  79. cmp r2, #0 //check if gpioa is high
  80. it ne //if is high
  81. bne waitingBranch //branch back to start of waiting branch
  82.  
  83. b loop //branch back to the beginning
  84.  
  85.  
  86. resetr7:
  87. ldr r7, =0
  88. b waitingBranch
  89.  
  90.  
  91.  
  92.  
  93. .align 4
  94. ssegdata: // The LUT
  95. .byte 0x39 // C
  96. .byte 0x4F // 3
  97. .byte 0x5B // 2
  98. .byte 0x6D // 5
  99. .byte 0x7D // 6
  100. .byte 0x07 // 7
  101. .byte 0x4F // 3
  102. .byte 0x3F // 0
  103.  
  104.  
  105. /* .byte 0x3F // 0
  106. .byte 0x06 // 1
  107. .byte 0x5B // 2
  108. .byte 0x4F // 3
  109. .byte 0x66 // 4
  110. .byte 0x6D // 5
  111. .byte 0x7D // 6
  112. .byte 0x07 // 7
  113. .byte 0x7F // 8
  114. .byte 0x67 // 9
  115. .byte 0x77 // A
  116. .byte 0x7C // B
  117. .byte 0x29 // C
  118. .byte 0x5E // D
  119. .byte 0x79 // E
  120. .byte 0x71 // F
  121. */
Add Comment
Please, Sign In to add comment