• LED灯实验--汇编


     asm-led.S

    1. .text
    2. .global _start
    3. _start:
    4. /* 1. led灯的初始化 */
    5. /* 1.1 使能GPIOE、DPIOF外设控制器的时钟 */
    6. ldr r0, =0x50000A28
    7. ldr r1, [r0]
    8. orr r1, r1, #(0x3 << 4)
    9. str r1, [r0]
    10. /* 1.2 设置PE10、PE8PF10引脚为输出模式 */
    11. ldr r0, =0x50006000
    12. ldr r1, [r0]
    13. bic r1, r1, #(0x3 << 16)
    14. orr r1, r1, #(0x1 << 16)
    15. bic r1, r1, #(0x3 << 20)
    16. orr r1, r1, #(0x1 << 20)
    17. str r1, [r0]
    18. ldr r0, =0x50007000
    19. ldr r1, [r0]
    20. bic r1, r1, #(0x3 << 20)
    21. orr r1, r1, #(0x1 << 20)
    22. str r1, [r0]
    23. /* 1.3 设置PE10、PE8PF10引脚为推挽输出 */
    24. ldr r0, =0x50006004
    25. ldr r1, [r0]
    26. bic r1, r1, #(0x1 << 8)
    27. bic r1, r1, #(0x1 << 10)
    28. str r1, [r0]
    29. ldr r0, =0x50007004
    30. ldr r1, [r0]
    31. bic r1, r1, #(0x1 << 10)
    32. str r1, [r0]
    33. /* 1.4 设置PE10、PE8PF10引脚为低速模式 */
    34. ldr r0, =0x50006008
    35. ldr r1, [r0]
    36. bic r1, r1, #(0x3 << 16)
    37. bic r1, r1, #(0x3 << 20)
    38. str r1, [r0]
    39. ldr r0, =0x50007008
    40. ldr r1, [r0]
    41. bic r1, r1, #(0x3 << 20)
    42. str r1, [r0]
    43. /* 1.5 设置PE10、PE8PF10引脚禁止上拉和下拉电阻 */
    44. ldr r0, =0x5000600C
    45. ldr r1, [r0]
    46. bic r1, r1, #(0x3 << 16)
    47. bic r1, r1, #(0x3 << 20)
    48. str r1, [r0]
    49. ldr r0, =0x5000700C
    50. ldr r1, [r0]
    51. bic r1, r1, #(0x3 << 20)
    52. str r1, [r0]
    53. /* led1灯的初始化完成 */
    54. loop:
    55. /* 设置PE10引脚输出高电平, 点亮LED1*/
    56. ldr r0, =0x50006014
    57. ldr r1, [r0]
    58. orr r1, r1, #(0x1 << 10)
    59. str r1, [r0]
    60. bl delay_1s
    61. /* 设置PE10引脚输出低电平, 熄灭LED1*/
    62. ldr r0, =0x50006014
    63. ldr r1, [r0]
    64. bic r1, r1, #(0x1 << 10)
    65. str r1, [r0]
    66. bl delay_1s
    67. /* 设置PF10引脚输出低电平, 点亮LED2*/
    68. ldr r0, =0x50007014
    69. ldr r1, [r0]
    70. orr r1, r1, #(0x1 << 10)
    71. str r1, [r0]
    72. bl delay_1s
    73. /* 设置PF10引脚输出低电平, 熄灭LED2*/
    74. ldr r0, =0x50007014
    75. ldr r1, [r0]
    76. bic r1, r1, #(0x1 << 10)
    77. str r1, [r0]
    78. bl delay_1s
    79. /* 设置PE8引脚输出高电平, 点亮LED3*/
    80. ldr r0, =0x50006014
    81. ldr r1, [r0]
    82. orr r1, r1, #(0x1 << 8)
    83. str r1, [r0]
    84. bl delay_1s
    85. /* 设置PE8引脚输出低电平, 熄灭LED3*/
    86. ldr r0, =0x50006014
    87. ldr r1, [r0]
    88. bic r1, r1, #(0x1 << 8)
    89. str r1, [r0]
    90. bl delay_1s
    91. b loop
    92. @ 大概1s的延时函数
    93. delay_1s:
    94. mov r3, #0x10000000
    95. mm:
    96. cmp r3, #0
    97. subne r3, r3, #1
    98. bne mm
    99. mov pc, lr
    100. .end

    效果图: 

  • 相关阅读:
    C语言_字符串与指针的爱恨情仇
    学习C++第二课
    Ubuntu部署运行ORB-SLAM2
    Java和Vue项目打包并进行服务器部署
    Shell之函数与数组
    差分约束学习笔记
    JVM及其垃圾回收机制(GC)
    Mapping 设计指南
    外包干了一个月,技术明显进步。。。。。
    RF学习——器件的非线性失真分析
  • 原文地址:https://blog.csdn.net/qq_53268516/article/details/133683717