5.22 ARM点灯作业


.text
.global _start

_start:
	/*************LED1点灯PE10**************/
@led1初始化函数,只初始化一次

LED1_INIT:
@1.通过RCC_AHB4_ENSETR寄存器,设置GPIoz组控制器器使能0x50000A28[4] = 1
	ldr r0,=0x50000A28
	ldr r1,[r0]
	orr r1,r1,#(0x1<<4)
	str r1,[r0]

@2.通过GPIOE_MODER寄存器,设置PE10引脚为输出模式0x50006000[21:20] = 01
	ldr r2,=0x50006000
	ldr r3,[r2]
	and r3,r3,#(~(0x1<<21))
	orr r3,r3,#(0x1<<20)
	str r3,[r2]

@3.通过GPIOE_OTYPER寄存器,设置PE10引脚为推挽输出模式0x50006004 [10]=0
	ldr r4,=0x50006004
	ldr r5,[r4]
	and r5,r5,#(~(0x1<<10))
	str r5,[r4]

@4 .通过GPIOE_OSPEEDR寄存器,设置PE10引脚为低速输出0x50006008[21:20] =00
	ldr r6,=0x50006008
	ldr r7,[r6]
	and r7,r7,#(~(0x1<<21))
	and r7,r7,#(~(0x1<<20))
	str r7,[r6]

@5.通过GIOE PUPDR寄存器,设置PE10引脚禁止上下拉电阻0x5000600c[21:20] = 00
	ldr r8,=0x5000600c
	ldr r9,[r8]
	and r9,r9,#(~(0x1<<21))
	and r9,r9,#(~(0x1<<20))
	str r9,[r8]



LED2_INIT:
@1.通过RCC_AHB4_ENSETR寄存器,设置GPIoz组控制器器使能0x50000A28[4] = 1
	ldr r0,=0x50000A28
	ldr r1,[r0]
	orr r1,r1,#(0x1<<5)
	str r1,[r0]

@2.通过GPIOE_MODER寄存器,设置PF10引脚为输出模式0x50007000[21:20] = 01
	ldr r2,=0x50007000
	ldr r3,[r2]
	and r3,r3,#(~(0x1<<21))
	orr r3,r3,#(0x1<<20)
	str r3,[r2]

@3.通过GPIOE_OTYPER寄存器,设置PF10引脚为推挽输出模式0x50007004 [10]=0
	ldr r4,=0x50007004
	ldr r5,[r4]
	and r5,r5,#(~(0x1<<10))
	str r5,[r4]

@4 .通过GPIOE_OSPEEDR寄存器,设置PF10引脚为低速输出0x50007008[21:20] =00
	ldr r6,=0x50007008
	ldr r7,[r6]
	and r7,r7,#(~(0x1<<21))
	and r7,r7,#(~(0x1<<20))
	str r7,[r6]

@5.通过GIOE PUPDR寄存器,设置PF10引脚禁止上下拉电阻0x5000700c[21:20] = 00
	ldr r8,=0x5000700c
	ldr r9,[r8]
	and r9,r9,#(~(0x1<<21))
	and r9,r9,#(~(0x1<<20))
	str r9,[r8]

LED3_INIT:
@1.通过RCC_AHB4_ENSETR寄存器,设置GPIoz组控制器器使能0x50000A28[4] = 1
	ldr r0,=0x50000A28
	ldr r1,[r0]
	orr r1,r1,#(0x1<<4)
	str r1,[r0]

@2.通过GPIOE_MODER寄存器,设置PE8引脚为输出模式0x50006000[21:20] = 01
	ldr r2,=0x50006000
	ldr r3,[r2]
	and r3,r3,#(~(0x1<<17))
	orr r3,r3,#(0x1<<16)
	str r3,[r2]

@3.通过GPIOE_OTYPER寄存器,设置PE8引脚为推挽输出模式0x50006004 [10]=0
	ldr r4,=0x50006004
	ldr r5,[r4]
	and r5,r5,#(~(0x1<<8))
	str r5,[r4]

@4 .通过GPIOE_OSPEEDR寄存器,设置PE8引脚为低速输出0x50006008[21:20] =00
	ldr r6,=0x50006008
	ldr r7,[r6]
	and r7,r7,#(~(0x1<<17))
	and r7,r7,#(~(0x1<<16))
	str r7,[r6]

@5.通过GIOE PUPDR寄存器,设置PE8引脚禁止上下拉电阻0x5000600c[21:20] = 00
	ldr r8,=0x5000600c
	ldr r9,[r8]
	and r9,r9,#(~(0x1<<17))
	and r9,r9,#(~(0x1<<16))
	str r9,[r8]



loop:
	
bl LED1_ON
bl delay_1s
bl LED1_OFF
bl delay_1s
bl LED2_ON
bl delay_1s
bl LED2_OFF
bl delay_1s
bl LED3_ON
bl delay_1s
bl LED3_OFF
bl delay_1s
	b loop



@led1点亮函数
LED1_ON:
	@通过GPIOE_ODR寄存器设置PE10引脚输出高电平0x50006014[10] = 1
	ldr r10,=0x50006014
	ldr r11,[r10]
	orr r11,r11,#(0x1<<10)
	str r11,[r10]
	mov pc,lr
	
 @led1熄灭函数
 LED1_OFF:
	@通过GPIOF ODR寄存器设置PE10引脚输出低电平0x50006014[10] = 0
	ldr r0,=0x50006014
	ldr r12,[r0]
	and r12,r12,#(~(0x1<<10))
	str r12,[r0]
	mov pc,lr


@led2点亮函数
LED2_ON:
	@通过GPIOE_ODR寄存器设置PF10引脚输出高电平0x50007014[10] = 1
	ldr r10,=0x50007014
	ldr r11,[r10]
	orr r11,r11,#(0x1<<10)
	str r11,[r10]
	mov pc,lr
	
 @led2熄灭函数
 LED2_OFF:
	@通过GPIOF ODR寄存器设置PF10引脚输出低电平0x50007014[10] = 0
	ldr r0,=0x50007014
	ldr r12,[r0]
	and r12,r12,#(~(0x1<<10))
	str r12,[r0]
	mov pc,lr

@led3点亮函数
LED3_ON:
	@通过GPIOE_ODR寄存器设置PE10引脚输出高电平0x50006014[10] = 1
	ldr r10,=0x50006014
	ldr r11,[r10]
	orr r11,r11,#(0x1<<8)
	str r11,[r10]
	mov pc,lr
	
 @led3熄灭函数
 LED3_OFF:
	@通过GPIOF ODR寄存器设置PE10引脚输出低电平0x50006014[10] = 0
	ldr r0,=0x50006014
	ldr r12,[r0]
	and r12,r12,#(~(0x1<<8))
	str r12,[r0]
	mov pc,lr

delay_1s:
	mov r3, #0x10000000
	mm:
	cmp r3, #0
	subne r3, r3, #1
	bne mm
	mov pc,lr

.end

你可能感兴趣的:(笔记,嵌入式硬件)