·12.21

作业:实现三个灯同时闪烁

 

.text 
.global _start
_start: 
    @设置GPIO的时钟使能
    ldr r0,=0x50000A28
    ldr r1,[r0]
    orr r1,r1,#(0x1<<4)
    str r1,[r0]

    @设置PE10为输出
    ldr r0,=0x50006000
    ldr r1 ,[r0]
    bic r1,r1,#(0x3<<20)
    orr r1,r1,#(0x1<<20)
    str r1,[r0]
   
    ldr r0,=0x50006004
    ldr r1 ,[r0]
    bic r1,r1,#(0x1<<10)
    str r1,[r0]
@设置PE10为低速输出
 ldr r0,=0x50006008
    ldr r1 ,[r0]
    bic r1,r1,#(0x3<<20)
    str r1,[r0]
@设置PE10为无上拉下拉
        ldr r0,=0x5000600C
         ldr r1 ,[r0]
         bic r1,r1,#(0x3<<20)
        str r1,[r0]


        @====设置LED2(PF10)===============
         @给PE8设置时钟使能,
        ldr r0,=0x50000A28
        ldr r1,[r0]
        orr r1,r1,#(0x1<<5)
        str r1,[r0]

         @给PF10设置为输出窗口moder[21::20]->01
        ldr r0,=0x50007000
        ldr r1,[r0]
        bic r1,r1,#(0x3<<20)
        orr r1,r1,#(0x1<<20)
        str r1,[r0]

        @给PF10设置为推挽输出otyper
        ldr r0,=0x50007004
        ldr r1,[r0]
        bic r1,r1,#(0x1<<10)
        str r1,[r0]


         @给PF10设置为低速输出[21:20]->0
          ldr r0,=0x50007008
        ldr r1,[r0]
        bic r1,r1,#(0x3<<20)
        str r1,[r0]

         @给PF10设置为无上下推拉输出 pupdr  [21:20]->00
         ldr r0,=0x5000700c
        ldr r1,[r0]
        bic r1,r1,#(0x3<<20)
        str r1,[r0]

         @设置灯闪
         @========================设置LED3(PE8)================
         @给PE8设置时钟使能
        ldr r0,=0x50000A28
        ldr r1,[r0]
        orr r1,r1,#(0x1<<4)
        str r1,[r0]

         @给PE8设置为输出窗口moder[17::16]->01
        ldr r0,=0x50006000
        ldr r1,[r0]
        bic r1,r1,#(0x3<<16)
        orr r1,r1,#(0x1<<16)
        str r1,[r0]

        @给PE8设置为推挽输出otyper[8]->0
        ldr r0,=0x50006004
        ldr r1,[r0]
        bic r1,r1,#(0x1<<8)
        str r1,[r0]


         @给PE8设置为低速输出OSPEEDR[17:16]->00
          ldr r0,=0x50006008
        ldr r1,[r0]
        bic r1,r1,#(0x3<<16)
        str r1,[r0]

         @给PF10设置为无上下推拉输出 pupdr  [17::16]->00
         ldr r0,=0x5000600c
        ldr r1,[r0]
        bic r1,r1,#(0x3<<16)
        str r1,[r0]

         @设置灯闪
         
flash:
        bl led1_on
        bl led2_on
        bl led3_on
        bl delay
        bl led1_off
        bl led2_off
        bl led3_off
        bl delay
        b flash
led1_on:
@设置为输出高电平  ODR(PE10)
         ldr r0,=0x50006014
       ldr r1 ,[r0]
         orr r1,r1,#(0x1<<10)
          str r1,[r0]
         mov pc,lr 
led2_on:
@设置为输出高电平 ODR(PF10)
         ldr r0,=0x50007014
       ldr r1 ,[r0]
         orr r1,r1,#(0x1<<10)
          str r1,[r0]
         mov pc,lr 
led3_on:
@设置为输出高电平 ODR(PE8)
         ldr r0,=0x50006014
       ldr r1 ,[r0]
         orr r1,r1,#(0x1<<8)
          str r1,[r0]
         mov pc,lr 
 led1_off:
 @设置为低电平 ODR (PE10)
 ldr r0,=0x50006014
    ldr r1 ,[r0]
    bic r1,r1,#(0x1<<10)
    str r1,[r0]
    mov pc,lr 
 led2_off:
 @设置为低电平 ODR (PF10)
 ldr r0,=0x50007014
    ldr r1 ,[r0]
    bic r1,r1,#(0x1<<10)
    str r1,[r0]
    mov pc,lr 
    led3_off:
 @设置为低电平 ODR (PE8)
 ldr r0,=0x50006014
    ldr r1 ,[r0]
    bic r1,r1,#(0x1<<8)
    str r1,[r0]
    mov pc,lr 
delay:
    ldr r3,=0x10000000
mm:
    cmp r3,#0
    subne r3,r3,#1
    bne mm
    mov pc,lr

.end

·12.21_第1张图片

你可能感兴趣的:(java,开发语言)