Keys and buzzer Control Based on fl2440 Development Board

Source: Internet
Author: User
Document directory
  • Basic Principles:
  • Logical operation commands:
  •  
  • Comparison command:
Basic Principles:

Logical operation commands:

And r0, R0, #0x01; R0 = R0 & 0x01 retrieve R0's percentile data

ORR r0, R0, # 0xff; R0 = R0 | 0xff

LSR logical shift right logic right shift

RX, LSR # N or RX, LSR, Rn

Register = register> shift

EOR logical exclusive or

EOR r0, R0, #3 reverse r0, 0 and 1 in

Bic (bit clear)

Bic r0, # % 0110; note that the binary format is %

Comparison command:

CMP R1, #10 compare and set CPSR

Tst

TEQ

Condition judgment mark:

 

 

Register address R/W description reset value
Gpfcon 0x56000050 R/W configures the pins of port F 0x0
Gpfdat 0x56000054 R/W the data register for port f undef.
Gpfup 0x56000058 R/W pull-up disable register for port F 0x000
Reserved 0x5620.5c ---

 

00 = input 01 = Output

1) set gpf0/2/3/4 to input

00 00 00 01 00

 

 

 

Area button, code, readonly

Entry


Start
Prohibit pull-up Resistance
LDR R1, = 0x56000058
LDR R2, = 0xff
STR R2, [R1]

; Set GPF0--GPF4 as input

LDR R3, = 0x56000050
LDR R4, = 0x55555404
STR R4, [R3]

; Set the corresponding port of the buzzer to the output
LDR R1, = 0x56000010
LDR R2, = 0x01
STR R2, [R1]



Loop
; Read data
LDR R3, = 0x56000054
LDR R4, [R3]; read data

; Determines whether a key is pressed
11100010
; Will be unique in the key-independent position 1

ORR R4, R4, #0xe2

CMP R4, # 0xff

Beq beep_down
B beep_on

B Loop
; Close the buzzer
Beep_down
LDR R1, = 0x56000014
LDR R2, = 0x0
STR R2, [R1]
B Loop

Beep_on
LDR R1, = 0x56000014
LDR R2, = 0x1
STR R2, [R1]
B Loop

End

---------------------------------------------------------------------- Persistently strives for Excellence ------------------------------------------------------------------------------

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.