How to turn it into a dark, brighten after press the
; RCC register address image
RCC_BASE EQU 0 x40021000
RCC_APB2ENR EQU (RCC_BASE + 0 x18)
; GPIO port C register address image
GPIOC_BASE EQU 0 x40011000
GPIOC_CRL EQU (GPIOC_BASE + 0 x00)
GPIOC_CRH EQU (GPIOC_BASE + 0 x04)
GPIOC_IDR EQU (GPIOC_BASE + 0 x08)
GPIOC_ODR EQU (GPIOC_BASE + 0 x0c)
GPIOC_BSRR EQU (GPIOC_BASE + 0 x10)
GPIOC_BRR EQU (GPIOC_BASE + 0 x14)
GPIOC_LCKR EQU (GPIOC_BASE + 0 x18)
IOPCEN EQU 0 x00000010
; GPIO D mouth register address image
GPIOD_BASE EQU 0 x40011400
GPIOD_CRL EQU (GPIOD_BASE + 0 x00)
GPIOD_CRH EQU (GPIOD_BASE + 0 x04)
GPIOD_IDR EQU (GPIOD_BASE + 0 x08)
GPIOD_ODR EQU (GPIOD_BASE + 0 x0c)
GPIOD_BSRR EQU (GPIOD_BASE + 0 x10)
GPIOD_BRR EQU (GPIOD_BASE + 0 x14)
GPIOD_LCKR EQU (GPIOD_BASE + 0 x18)
IOPDEN EQU 0 x00000020
; Constants defined
Bit12 EQU 0 x00001000
; An image with address
BitAlias_BASE EQU 0 x42000000; Equipment woman with alias area starting address
Bit_BASE EQU 0 x40000000; Equipment for a belt region starting address
; Button bits with defined
PortDbit12 EQU (BitAlias_BASE + ((GPIOD_IDR - Bit_BASE) * 0 x20 + 12 * 4))
The Key EQU PortDbit12
; LED a definition with
PortCbit7 EQU (BitAlias_BASE + ((GPIOC_ODR - Bit_BASE) * 0 x20 + 7 * 4))
LED2 EQU PortCbit7
MSP_TOP EQU 0 x20005000; The main stack starting value
; To scale
AREA RESET, DATA, READONLY
DCD MSP_TOP; Initialize the stack
DCD Start; Reset vector
DCD NMI_Handler; NMI Handler
DCD HardFault_Handler; Hard Fault Handler
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
SPACE 20; Room 20 bytes
; Code
AREA. | text |, CODE, READONLY
; The main program began to
ENTRY
; Instruction program starts from here
Start
LDR R1=RCC_APB2ENR
LDR R0, (R1), Read the APB2 peripheral clock can make register (RCC_APB2ENR)
ORR R0, # (IOPCEN: OR: IOPDEN)
STR R0, (R1), Can write APB2 peripheral clock can register, GPIOC, GPIOD clock
LDR R0=0 x33444444; PC (7.. 6] into a 50 MHZ push-pull output
LDR R1=GPIOC_CRL;
STR R0, (R1)
LDR R0=0 x44484444; PD [12] pull up input into a
LDR R1=GPIOD_CRH;
STR R0, (R1)
LDR R1=GPIOD_ODR
LDR R0, (R1), Read the ODR GPIOD
ORR R0, Bit12; Modify the
STR R0, (R1), Write the ODR GPIOD
LDR R1=GPIOC_BSRR
LDR R0=0 x00400000; BSRR high clear, light leds on PC6
LDR R2=0 x00000040; BSRR low setting, extinguishing PC6 LED
LDR R3,=Key; Load Key bit with address
LDR R4,=LED2; Load the LED2 woman with address
LOOP
STR R0, (R1), Light PC10 LED
PUSH {R0}
MOV R0, # 500
BL. W DELAY_NMS; Delay 300 ms
POP {R0}
STR R2 (R1); Go out on PC10 LED
PUSH {R0}
MOV R0, # 500
BL. W DELAY_NMS; Delay 300 ms
POP {R0}
LDR R5, (R3); Read the Key Key
STR R5, (R4); Output to the LED2
B LOOP; Cycle
CodePudding user response:
Take the output to LED2 button input values, the following referenceLDR R5, (R3); Read the Key Key
MVN R5, R5;
BIC R5, R5, # 0 xfffffffe;
STR R5, (R4); Output to the LED2