Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 0.90 KB | None | 0 0
  1.  
  2.  
  3. .include "asm_registers.i"
  4. .section .text
  5. .global rcc_config
  6. .global led_config
  7. .global delay_ms
  8. .global led_toggle
  9. .global pseudo_main
  10.  
  11. .syntax unified
  12. .cpu cortex-m3
  13. .fpu softvfp
  14. .thumb
  15. .align
  16.  
  17. rcc_config:
  18.     LDR R0, =RCC_BASE
  19.     LDR R1, [R0, #RCC_APB2ENR]
  20.     LDR R2, =(1<<3)
  21.     ORR R1, R1, R2
  22.     STR R1, [R0, #RCC_APB2ENR]
  23.     BX LR
  24.  
  25. led_config:
  26.     LDR R0, =GPIOB_BASE
  27.     LDR R1, [R0, #GPIO_CRH]
  28.     LDR R2, =~(3<<16)
  29.     AND R1, R1, R2
  30.     LDR R2, =(3<<16)
  31.     ORR R1, R1, R2
  32.     STR R1, [R0, #GPIO_CRH]
  33.     BX LR
  34.  
  35. delay_ms:
  36.     CMP R0, #0
  37.     BEQ end
  38.     SUBS R0, #1
  39.     MOV.W R1, #1000
  40. loop:
  41.     SUBS R1, #1
  42.     CMP R1, #0
  43.     NOP
  44.     NOP
  45.     NOP
  46.     BNE loop
  47.     B delay_ms
  48. end:
  49.     BX LR
  50.  
  51. led_toggle:
  52.     LDR R0, =GPIOB_BASE
  53.     LDR R1, [R0, #GPIO_ODR]
  54.     EOR R1, #(1<<12)
  55.     STR R1, [R0, #GPIO_ODR]
  56.     BX LR
  57.  
  58. pseudo_main:
  59.     BL rcc_config
  60.     BL led_config
  61.  
  62. while_loop:
  63.     BL led_toggle
  64.     MOV.W R0, #1000
  65.     BL delay_ms
  66.     B while_loop
  67.  
  68.     BX LR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement