ARM day4 作业

发布时间:2023年12月21日

1,点亮三个灯,并闪烁

.text 
.global _start
_start:

@led1灯
    @设置GPIOE时钟使能   RCC_MP_AHB4ENSETR[4]->1  @0X50000A28
    LDR R0,=0X50000A28
    LDR R1,[R0]
    ORR R1,R1,#(0x1<<4)
    STR R1,[R0]

    @设置PE10为输出 GPIOE_MODER[21:20]->01   0X50006000
    LDR  R0,=0X50006000
    LDR R1,[R0]
    BIC R1,R1,#(0x3<<20)
    ORR R1,R1,#(0x1<<20)
    STR R1,[R0]

    @设置PE10为推挽输出  GPIOE_OTYPER[10]->0  0X50006004
    LDR R0,=0X50006004
    LDR R1,[R0]
    BIC R1,R1,#(0x1<<10)
    STR R1,[R0]

    @设置PE10为低速输出  GPIOE_OSPEEDR[21:20]->00  0X50006008
    LDR R0,=0X50006008
    LDR R1,[R0]
    BIC R1,R1,#(0x3<<20)
    STR R1,[R0]

    @设置PE10输出时无上拉下拉电阻  GPIOE_PUPDR[21:20]->00  0X5000600C
    LDR R0,=0X5000600C
    LDR R1,[R0]
    BIC R1,R1,#(0x3<<20)
    STR R1,[R0]


@led2灯

   LDR R2,=0X50000A28
    LDR R3,[R2]
    ORR R3,R3,#(0x1<<5)
    STR R3,[R2]

 
    LDR  R2,=0X50007000
    LDR R3,[R2]
    BIC R3,R3,#(0x3<<20)
    ORR R3,R3,#(0x1<<20)
    STR R3,[R2]

  
    LDR R2,=0X50007004
    LDR R3,[R2]
    BIC R3,R3,#(0x1<<10)
    STR R3,[R2]

    
    LDR R2,=0X50007008
    LDR R3,[R2]
    BIC R3,R3,#(0x3<<20)
    STR R3,[R2]

    
    LDR R2,=0X5000700C
    LDR R3,[R2]
    BIC R3,R3,#(0x3<<20)
    STR R3,[R2]

    


@led3灯
    
    LDR  R4,=0X50006000
    LDR R5,[R4]
    BIC R5,R5,#(0x3<<16)
    ORR R5,R5,#(0x1<<16)
    STR R5,[R4]

  
    LDR R4,=0X50006004
    LDR R5,[R4]
    BIC R5,R5,#(0x1<<8)
    STR R5,[R4]


    LDR R4,=0X50006008
    LDR R5,[R4]
    BIC R5,R5,#(0x3<<16)
    STR R5,[R4]

    
    LDR R4,=0X5000600C
    LDR R5,[R4]
    BIC R5,R5,#(0x3<<16)
    STR R5,[R4]

loop:

    bl led1_on
    bl led2_on
    bl led3_on
    bl delay
    bl led1_off
    bl led2_off
    bl led3_off
    bl delay
    b loop

led1_on:
    LDR R0,=0X50006014
    LDR R1,[R0]
    ORR R1,R1,#(0x1<<10)
    STR R1,[R0]
    mov pc,lr

led1_off:
    LDR R0,=0X50006014
    LDR R1,[R0]
    BIC R1,R1,#(0x1<<10)
    STR R1,[R0]
    mov pc,lr

led2_on:
    LDR R2,=0X50007014
    LDR R3,[R2]
    ORR R3,R3,#(0x1<<10)
    STR R3,[R2]
    mov pc,lr

led2_off:
    LDR R2,=0X50007014
    LDR R3,[R2]
    BIC R3,R3,#(0x1<<10)
    STR R3,[R2]
    mov pc,lr

led3_on:
    LDR R4,=0X50006014
    LDR R5,[R4]
    ORR R5,R5,#(0x1<<8)
    STR R5,[R4]
    mov pc,lr

led3_off:
    LDR R4,=0X50006014
    LDR R5,[R4]
    BIC R5,R5,#(0x1<<8)
    STR R5,[R4]
    mov pc,lr

delay:
    LDR R6,=0X10000000
mm:
    cmp r6,#0
    subne r6,r6,#1
    bne mm
    mov pc,lr

.end

2,思维导图

文章来源:https://blog.csdn.net/weixin_71279393/article/details/135139498
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。