Файл: Embedded system development and labs for ARM (R. Muresan, 2005).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 2348

Скачиваний: 4

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Embedded Systems Development and Labs; The English Edition

rZDIDES0=( 2<<30) |(1<<28)|LCD_ACTIVE_BUFFER; // inc

rZDICNT0=( 2<<28)|(1<<26)|(3<<22)|(0<<20)|(LCD_BUF_SIZE);

//

|

|

|

|

| ---->0 = Disable

DMA

//

|

|

|

|

------------>Int. whenever

transferred

//

|

|

|--------------------

>Write time on the fly

//

|

|----------------------------

>Block(4-word) transfer mode

//

|------------------------------------

>whole service

//reEnable ZDMA transfer

rZDICNT0 |= (1<<20);

//after ES3

rZDCON0=0x1; // start!!!

Delay(500);

//while(ucZdma0Done);

//wait for DMA finish

}

5.1.8 Exercises

Refer to the sample program; display the 4 x 4 keyboard values on the LCD panel.

5.2 The 4 x 4 Keyboard Control Lab

5.2.1 Purpose

● Understand the design method of keyboard interrupt control program. ● Understand the design of the keyboard interrupt test program.

● Understand the interrupt service routine programming using the ARM core processor.

5.2.2 Lab Equipment

● Hardware: Embest S3CEV40 hardware platform, Embest Standard/Power Emulator, PC. ● Software: Embest IDE 2003, Windows 98/2000/NT/XP operation system.

5.2.3 Content of the Lab

Develop a project that accepts the keys of the keyboard pad through interrupt service routine and display the values on the 8-SEG LED.

5.2.4 Principles of the Lab

For the matrix keyboard interface, there are normally three ways of getting the keyboard values: through interrupts, through scanning, and through inversion.

Interrupts: When a key is pressed, CPU will receive an interrupt signal. The interrupt service routine will

209


Embedded Systems Development and Labs; The English Edition

read the keyboard status on the data bus through different addresses and determine which key is pressed.

Scanning: Send low voltage to one horizontal line and high level to the other horizontal lines. If any vertical line is low, the key that sits at the intersection of the selected row and column is pressed.

Inversion: Send low voltage to the horizontal lines and read the vertical lines. If any vertical line is low, it indicates one key is pressed on that column. Then send low voltage to the vertical lines and read the horizontal lines. If any horizontal line is low, it indicates one key is pressed on that row. The intersection of the identified row and column will give the position of the key.

5.2.5 Lab Design

1. Keyboard Hardware Circuit Design

1) 4 x 4 Keyboard

The 4 x 4 keyboard has 4 rows and 4 columns. The circuit is shown in Figure 5-12. Any pressed key will generate a pass route.

SB1

SB5

SB9

SB13

1

2

1

2

1

2

1

2

KEY

KEY

KEY

KEY

SB2

SB6

SB10

SB14

1

2

1

2

1

2

1

2

KEY

KEY

KEY

KEY

SB3

SB7

SB11

SB15

1

2

1

2

1

2

1

2

KEY

KEY

KEY

KEY

SB4

SB8

SB12

SB16

1

2

1

2

1

2

1

2

KEY

KEY

KEY

KEY

Figure 5-12 4 x 4 Keyboard Circuit

2) CPU Recognition Circuit

The keyboard recognition circuit is shown bellow:

210


Embedded Systems Development and Labs; The English Edition

R48

U10

U11

10KR51R54R55

14

VCCGND

7

10K10K10K

74HC541

L3

12

13

11

10

GND

6Y

6A

Y8

GND

L2

10

11

12

9

A4

5Y

5A

Y7

A8

L1

8

9

13

8

A3

4Y

4A

Y6

A7

L0

6

5

14

7

A2

D11

3Y

3A

Y5

A6

4

3

D3

15

6

A1

L3

1N4148

2Y

2A

Y4

A5

2

1

D2

16

5

D10

1Y

1A

R56

Y3

A4

D1

17

4

L2

1N4148

Y2

A3

74HC17

R58

10K

D0

18

3

L1

Y1

A2

D8

J7

10K

NGCS319

G2

A1

2

1N4148

20

1GND

VDD33

VCC

G1

L0

1

2

U9B

D7

3

1N4148

4

74HC087

74HC08

4

5

U9C

10 6

6

EXINT1

8

5

7

9

8

14

11

13

KEYBOARD

12

VDD33

U9D

74HC08

R63 R65 R68 R69

1.5K 1.5K 1.5K 1.5K

VDD33

Figure 5-13 4 x 4 Keyboard Recognition Circuit

3) Circuit Functionality

As shown in Figure5-13, the keyboard connection electric circuit, a 4×4 matrix keyboard port is expanded on the board. This keyboard supports the interrupt mode and the scanning mode. 4 data wires represent the rows and 4 address wires represent the columns. Row wires are connected with pull-up resistors to maintain high level. These row signals are used to generate the EXINT1 MCU’s interrupt signal through a 74HC08 AND gate. The column wires are connected with pull-down resistors to maintain low level. When some key is pressed down, the row wires are pulled to low level, which causes EXINT1 input to become low and activate the MCU interrupt system. After the interrupt is recognized, the pressed key can be found by scanning the rows and columns of the keyboard then the corresponding key is processed. Chip 74HC541 is selected through the chip select signal nGCS3. This guarantees that MCU reads the row wire’s information only when the keyboard is used. For example, if the key that connects pin1 and pin5 of J7 is pressed, the interrupt routine will read data using the following addresses (x means 0 or 1):

Xxx11101, A1 is logic low. Analyze whether the button on L0 line is pressed. Because the fourth pin on J7 is in the off status, and high logic on A4 causes that the first pin is disconnected with the fifth pin of J7, output of data bus from U10 is still 0xF

Xxx11011, A2 is low logic. Analyze whether the buttons on L1 line are pressed. Because the third pin of J7 is in the off status, and high logic on A4 causes that the first pin is disconnected with the fifth pin of J7, output of data bus from U10 is still 0xF.

Xxx10111, A3 is low logic. Analyze whether the buttons on L2 line are pressed. Because the second

211


Embedded Systems Development and Labs; The English Edition

pin of J7 is in the off status, and high logic on A4 causes that the first pin is disconnected with the fifth pin of J7, output of data bus from U10 is still 0xF.

Xxx01111, A4 is low logic. Analyze whether the buttons on L3 line are pressed. Because the first pin is connected with the fifth pin of J7, and low logic on A4 causes that input of data bus pass through the loop from U11 to U10, the output of data bus D0 is pulled down by U10 and becomes 0xE. The interrupt service routine (ISR) can analyze whether the button SB16 is pressed according to the rules.

The addresses and the data for the 16 keys are shown in Table 5-7.

Table 5-7. Key value decisions

A4

A3

A2

A1

A0

Address

D3

D2

D1

D0

Data

SB1

1

1

1

0

1

0xFDH

0

1

1

1

0x7H

SB2

1

1

0

1

1

0xFBH

0

1

1

1

0x7H

SB3

1

0

1

1

1

0xF7H

0

1

1

1

0x7H

SB4

0

1

1

1

1

0xEFH

0

1

1

1

0x7H

SB5

1

1

1

0

1

0xFDH

1

0

1

1

0xBH

SB6

1

1

0

1

1

0xFBH

1

0

1

1

0xBH

SB7

1

0

1

1

1

0xF7H

1

0

1

1

0xBH

SB8

0

1

1

1

1

0xEFH

1

0

1

1

0xBH

SB9

1

1

1

0

1

0xFDH

1

1

0

1

0xDH

SB10

1

1

0

1

1

0xFBH

1

1

0

1

0xDH

SB11

1

0

1

1

1

0xF7H

1

1

0

1

0xDH

SB12

0

1

1

1

1

0xEFH

1

1

0

1

0xDH

SB13

1

1

1

0

1

0xFDH

1

1

1

0

0xEH

SB14

1

1

0

1

1

0xFBH

1

1

1

0

0xEH

SB15

1

0

1

1

1

0xF7H

1

1

1

0

0xEH

SB16

0

1

1

1

1

0xEFH

1

1

1

0

0xEH

1

1

1

1

1

Initial

1

1

1

1

Initial

4) Key Display Control

When a key is pressed, the corresponding key value will be displayed on the 8-SEG LED. The circuit of 8-SEG LED is shown in Figure 5-14. (Refer to Section 4.6 “8-SEG LED Display Lab”)

212