ARM_汇编点灯


.text 
.global _start
_start: 

	/*~~~~~~~~~~~~~~~~~~~~~LED1点灯----->PE10~~~~~~~~~~~~~~~~~~~~~~*/
	/*~~~~~~~~~~~~~~~~~~~~~~~RCC章节初始化~~~~~~~~~~~~~~~~~~~~~~~~*/
RCC1_INIT:
	/*~~~~~~~~~~~~~~通过RCC_MP_AHB4ENSETR寄存器使能GPIOE组控制器 0x50000A28[4] = 1*/
	ldr r2,=0x50000A28
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 4)
	str r3,[r2]

	/*~~~~~~~~~~~~GPIO章节初始化**************/
LED1_INIT:
	@1.通过GPIOE_MODER寄存器设置PE10引脚为输出模式 0x50006000[21:20] = 01
	ldr r2,=0x50006000
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	orr r3,r3,#(0x1 << 20)
	str r3,[r2]
	@2.通过GPIOE_OTYPER寄存器设置PE10引脚为推挽输出类型 0x50006004[10] = 0
	ldr r2,=0x50006004
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 10)
	str r3,[r2]
	@3.通过GPIOE_OSPEEDR寄存器设置PE10引脚为低速输出模式 0x500060008[21:20] = 00
	ldr r2,=0x50006008
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	str r3,[r2]
	@4.通过GPIOE_PUPDR寄存器设置PE10引脚禁止上下拉电阻 0x5000600c[21:20] = 00
	ldr r2,=0x5000600c
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	str r3,[r2]


	/**********LED2点灯----->PF10**************/
	/*********RCC章节初始化********************/
RCC2_INIT:
	/**********通过RCC_MP_AHB4ENSETR寄存器使能GPIOE组控制器 0x50000A28[5] = 1**************/
	ldr r2,=0x50000A28
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 5)
	str r3,[r2]

	/**********GPIO章节初始化**************/
LED2_INIT:
	@1.通过GPIOE_MODER寄存器设置PF10引脚为输出模式 0x50006000[21:20] = 01
	ldr r2,=0x50007000
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	orr r3,r3,#(0x1 << 20)
	str r3,[r2]
	@2.通过GPIOE_OTYPER寄存器设置PF10引脚为推挽输出类型 0x50006004[10] = 0
	ldr r2,=0x50007004
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 10)
	str r3,[r2]
	@3.通过GPIOE_OSPEEDR寄存器设置PF10引脚为低速输出模式 0x500060008[21:20] = 00
	ldr r2,=0x50007008
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	str r3,[r2]
	@4.通过GPIOE_PUPDR寄存器设置PF10引脚禁止上下拉电阻 0x5000600c[21:20] = 00
	ldr r2,=0x5000700c
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 20)
	str r3,[r2]

	/**********LED3点灯----->PE8**************/
	/*********RCC章节初始化********************/
RCC3_INIT:
	/**********通过RCC_MP_AHB4ENSETR寄存器使能GPIOE组控制器 0x50000A28[4] = 1**************/
	ldr r2,=0x50000A28
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 4)
	str r3,[r2]
	/**********GPIO章节初始化**************/
LED3_INIT:
	@1.通过GPIOE_MODER寄存器设置PE8引脚为输出模式 0x50006000[17:16] = 01
	ldr r2,=0x50006000
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 16)
	orr r3,r3,#(0x1 << 16)
	str r3,[r2]
	@2.通过GPIOE_OTYPER寄存器设置PE8引脚为推挽输出类型 0x50006004[8] = 0	
	ldr r2,=0x50006004
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 8)
	str r3,[r2]
	@3.通过GPIOE_OSPEEDR寄存器设置PE8引脚为低速输出模式 0x500060008[17:16] = 00
	ldr r2,=0x50006008
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 16)
	str r3,[r2]
	@4.通过GPIOE_PUPDR寄存器设置P引脚禁止上下拉电阻 0x5000600c[17:16] = 00
	ldr r2,=0x5000600c
	ldr r3,[r2]
	bic r3,r3,#(0x3 << 16)
	str r3,[r2]
loop:
	bl LED3_ON
	bl delay_1s
	bl LED3_OFF
	bl delay_1s
	
	bl LED2_ON
	bl delay_1s
	bl LED2_OFF
	bl delay_1s

	bl LED1_ON
	bl delay_1s
	bl LED1_OFF
	bl delay_1s
	b loop
LED1_ON:
	@1.通过GPIOE_ODR寄存器设置PE10引脚为输出高电平 0x50006014[10] = 1	
	ldr r2,=0x50006014
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 10)
	str r3,[r2]
	mov pc,lr
LED1_OFF:
	@1.通过GPIOE_ODR寄存器设置PE10引脚为输出低电平 0x50006014[10] = 0
	ldr r2,=0x50006014
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 10)
	str r3,[r2]
	mov pc,lr	
LED2_ON:
	@1.通过GPIOE_ODR寄存器设置PF10引脚为输出高电平 0x50006014[10] = 1	
	ldr r2,=0x50007014
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 10)
	str r3,[r2]
	mov pc,lr
LED2_OFF:
	@1.通过GPIOE_ODR寄存器设置PF10引脚为输出低电平 0x50006014[10] = 0
	ldr r2,=0x50007014
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 10)
	str r3,[r2]
	mov pc,lr	


LED3_ON:
	@1.通过GPIOE_ODR寄存器设置PE8引脚为输出高电平 0x50006014[8] = 1	
	ldr r2,=0x50006014
	ldr r3,[r2]
	orr r3,r3,#(0x1 << 8)
	str r3,[r2]
	mov pc,lr
LED3_OFF:
	@1.通过GPIOE_ODR寄存器设置PE8引脚为输出低电平 0x50006014[8] = 0
	ldr r2,=0x50006014
	ldr r3,[r2]
	bic r3,r3,#(0x1 << 8)
	str r3,[r2]
	mov pc,lr	

@ 大概1s的延时函数
delay_1s:
	mov r3, #0x10000000
	mm:
	cmp r3, #0
	subne r3, r3, #1
	bne mm
	mov pc, lr

.end

你可能感兴趣的:(arm开发,汇编,单片机)