mini2440(6) 我的第一个ARM汇编程序---LED灯裸机硬件控制程序(2)

最新的LED灯控制代码,四个LED灯同时亮、同时灭,反复循环,持续亮或者灭的时间大概1s


		
		
WTCON		EQU	0x53000000
INTMSK		EQU 0x4A000008
INTSUBMSK	EQU 0x4A00001C 

TIMEVERL	EQU 0x00124F80

GPBCON		EQU	0x56000010
GPBDAT		EQU	0x56000014

GPBCON_VAL	EQU	((1 << 10) | (1 << 12) | (1 << 14) | (1 << 16))
GPBDAT_ON	EQU (~((1 << 5) | (1 << 6) | (1 << 7) | (1 << 8)))
GPBDAT_OFF	EQU ((1 << 5) | (1 << 6) | (1 << 7) | (1 << 8))
		
		
			AREA Init, CODE, READONLY
		
			ENTRY
	
			;禁止看门狗定时器	
			LDR R0, =WTCON
			LDR R1, =0x0
			STR R1, [R0]
		
			;禁止中断
			LDR R0, =INTMSK
			LDR R1, =0xFFFFFFFF
			STR R1, [R0]
		
			;禁止SUB中断
			LDR R0, =INTSUBMSK
			LDR R1, =0x7FFF
			STR R1, [R0]
			
			LDR R0, =GPBCON
			LDR R1, =GPBCON_VAL
			STR R1, [R0]
			
LED_FLASH
			BL LED_ON
			BL LED_DELAY
			BL LED_OFF
			BL LED_DELAY
			B LED_FLASH
	
			B .	
				
LED_ON	
			LDR R0, =GPBDAT
			LDR R1, =GPBDAT_ON
			STR R1, [R0]
			MOV PC, LR
			
LED_OFF
			LDR R0, =GPBDAT
			LDR R1, =GPBDAT_OFF
			STR R1, [R0]
			MOV PC, LR
		
LED_DELAY	
			LDR	R3, =TIMEVERL
IN_LOOP
			SUBS R3, R3, #1
			BNE	IN_LOOP
			MOV PC, LR
		
		END


你可能感兴趣的:(c,汇编)