循环点灯
- RCC寄存器使能GPIOE、GPIOF组寄存器
- 修改GPIOx组寄存器下的值
- 通过GPIOx_MODER寄存器设置为输出模式
- 通过GPIOx_OTYOER寄存器设置为推挽输出类型
- 通过GPIOx_OSPEEDR寄存器设置为低速输出
- 通过GPIOx_PUPDR寄存器设置为禁止上下拉电阻
- 点灯 通过GPIOx_ODR寄存器设置为高电平
- 灭灯 通过GPIOx_ODR寄存器设置为低电平
.text
.global _start
_start: /**********LED1点灯**************/@用RCC寄存器使能GPIOE、GPIOF寄存器
RCC_INIT:@使能GPIOE组控制器ldr r0,=0x50000A28ldr r1,[r0]orr r1,r1,#(0x1<<4)str r1,[r0]@使能GPIOF组控制器ldr r0,=0x50000A28ldr r1,[r0]orr r1,r1,#(0x1<<5)str r1,[r0]LED1_INIT:
@修改GPIOE_MODER寄存器ldr r2,=0x50006000ldr r3,[r2]bic r3,r3,#(0x1<<21)orr r3,r3,#(0x1<<20)str r3,[r2]ldr r2,=0x50007000ldr r3,[r2]bic r3,r3,#(0x1<<21)orr r3,r3,#(0x1<<20)str r3,[r2] ldr r2,=0x50006000ldr r3,[r2]bic r3,r3,#(0x1<<17)orr r3,r3,#(0x1<<16)str r3,[r2] @修改GPIOE_OTYPER寄存器ldr r4,=0x50006004ldr r5,[r4]bic r5,r5,#(0x1<<10)str r5,[r4]ldr r4,=0x50007004ldr r5,[r4]bic r5,r5,#(0x1<<10)str r5,[r4]ldr r4,=0x50006004ldr r5,[r4]bic r5,r5,#(0x1<<8)str r5,[r4]@修改GPIOE_OSPEEDR寄存器ldr r6,=0x50006008ldr r7,[r6]bic r7,r7,#(0x1<<21)bic r7,r7,#(0x1<<20)str r7,[r6]ldr r6,=0x50007008ldr r7,[r6]bic r7,r7,#(0x1<<21)bic r7,r7,#(0x1<<20)str r7,[r6]ldr r6,=0x50006008ldr r7,[r6]bic r7,r7,#(0x1<<17)bic r7,r7,#(0x1<<16)str r7,[r6]@修改GPIOE_PUPDR寄存器ldr r8,=0x5000600Cldr r9,[r8]bic r9,r9,#(0x1<<21)bic r9,r9,#(0x1<<20)str r9,[r8]ldr r8,=0x5000700Cldr r9,[r8]bic r9,r9,#(0x1<<21)bic r9,r9,#(0x1<<20)str r9,[r8]ldr r8,=0x5000600Cldr r9,[r8]bic r9,r9,#(0x1<<17)bic r9,r9,#(0x1<<16)str r9,[r8]loop:bl LED1_ONbl delay_1sbl LED1_OFFbl delay_1sbl LED2_ONbl delay_1sbl LED2_OFFbl delay_1sbl LED3_ONbl delay_1sbl LED3_OFFbl delay_1sb loopLED1_ON:ldr r10,=0x50006014ldr r11,[r10]orr r11,r11,#(0x1<<10)str r11,[r10]mov pc,lrLED2_ON:ldr r10,=0x50007014ldr r11,[r10]orr r11,r11,#(0x1<<10)str r11,[r10]mov pc,lrLED3_ON:ldr r10,=0x50006014ldr r11,[r10]orr r11,r11,#(0x1<<8)str r11,[r10]mov pc,lr@ 大概1s的延时函数
delay_1s:mov r3, #0x10000000mm:cmp r3, #0subne r3, r3, #1bne mmmov pc,lrLED1_OFF:ldr r10,=0x50006014ldr r11,[r10]bic r11,r11,#(0x1<<10)str r11,[r10]mov pc,lrLED2_OFF:ldr r10,=0x50007014ldr r11,[r10]bic r11,r11,#(0x1<<10)str r11,[r10]mov pc,lrLED3_OFF:ldr r10,=0x50006014ldr r11,[r10]bic r11,r11,#(0x1<<8)str r11,[r10]mov pc,lr.end
效果图
思维导图