Guest User

Untitled

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