miércoles, 2 de enero de 2019

Programming PDF – Unit 6 Programming the basic PC hardware resources

(6)

Unit 6

Programming resources

basic hardware of the PC

SYSTEMS BASED ON MICROPROCESSORS

Degree in Computer Engineering

EPS – UAM

(6 )

Index

6. Programming of basic PC hardware resources

Keyboard
Timer

6.1.
6.2.
6.3. Real Time Clock (RTC).
6.4. Video and Screen Controller
6.5. Parallel port. Printer.
6.6. Serial Port Asynchronous (UART 8250).

(6)

6.1. Keyboard (I)

Based on an integrated Intel (8042)

The 8042 keyboard controller has 2 programmable I / O
(8-bit) parallel ports and 2 programmable serial inputs (TEST0,
TEST1).
Pins P26 and P27 are for sending CLK and DATA to the keyboard.
The serial inputs TEST0 and TEST1 are for receiving the CLK and the
DATA sent by the keyboard.

8042 [19659002] P20

P26

IRQ9
(IR1 PIC-0)

P27
TEST0

TEST1

CLK

DATA

+ Vcc

Connector
keyboard

GND

(6)

6.1. Keyboard (II)

The 8042 is a microcontroller
compatible with Intel MCS-48
(8048) and MCS-51 (8051) families.
It behaves like a PPI (Interface of
Programmable Peripheral) that allows
to implement customized interfaces for
different peripherals.
It has 2 KB of ROM memory
(8042) or EPROM (8742), 128 KB of
memory RAM, 2 ports prog. of I / O
of 8 bits, 2 serial inputs prog.,
internal counter of 8 bits, clock of 12
MHz, and other control signals and
special
Directions: 60h (REG ENTRY and
EXIT), 64h (REG. CONTROL and
STATE)

8042

REG.

ENTRY

REG.

DEPARTURE

REG. [19659002] STATE

REG.

CONTROL

ROM
(2 KB)

RAM

(128 KB)

(6)

6.1. Keyboard (III)

When transmitting clock signal (CLK) apart from the data, a serial line driver (UART) is not required
.
There are no problems with transmitting the clock because it is a very short
line.

+ Vcc

CLK

P26

P27

DATA

CLK

DATA

] TEST0

TEST1

Connector of the
keyboard

GND

CLK

DATA

A

0

1

2

3

4

5

6

7

PS

(6)

6.1. Keyboard (IV)

PC keyboard has 83 keys divided into 3 groups:

Function keys
Alphanumeric keyboard
Numeric keypad

Keyboard communicates with BIOS using INT 09h
] (PIC-0, IR1).

Each time the key is pressed / released, INT 09h is generated
Service routine or key code (SCAN
CODE) reading port 60h of the keypad controller.
Key code when releasing is the same as when pressing but
with bit of greater weight to 1.
Each time a key is pressed, the service routine
stores two bytes in a buffer in the BIOS memory:

Code ASCII corresponding or 00h in the case of special key
(F1, …, F12, shift, arrows, etc.).
Pulsed key identifier (SCAN CODE).

(6)

6.1. Keyboard (V)

You can press key combinations.
Normally modifier type keys (ALT,
CAPS, CONTROL) accompanied by other
keys.

Some combinations are not recognized by the
BIOS routines and do not generate any type of code.

Keys with special meaning:
Alt-Ctrl-Del (system load).
Ctrl- Pause (call INT 1Bh of the BIOS).
Pause (stop a program until the key is pressed).
Print Screen (call INT 5h to print screen by
printer)

(6)

6.1. Keyboard (VI)

Keyboard

Pressing or releasing key
sends KSCAN code
(KEYBOARD SCAN CODE)
that encodes the physical position of
the key on the keyboard.

] Keyboard controller (8042)

ROM program translates KSCAN
to SCAN CODE.
F1 to F12 keys, arrows, shift, etc. no
generate ASCII code.

83 keys

μC (8048, 8051)

Explore

matrix on the
keyboard and send the

KSCAN to the PC

TEST0.1

μC (8042)

SCAN CODE

Keyboard Buffer (DOS)

BIOS (Int 09h)

PIC-0

(INT 09h)

Word format

] ASCII-COUNTRY SCAN CODE

BIOS

(INT 09h)

ASCII USA

SCAN CODE

16-word buffer

KEYB.COM

(6)

6.1 . Keyboard (VII)

Cyclical buffer

0040: 001E … 0040: 003D IN BIOS VARIABLE ZONE

FULL ZONE

0040: 001E

0040: 003C
The pointers are offsets
of the segment 40h between

1E and 3C

When reading increments

the pointer in 2

POINTER
READING

POINTER
WRITING

(Position of the following

(Position of the next

character to be read)

character to be written)

A position (word) is left free. Se
can store up to 15 characters

(words) in the buffer of 16 words

ASCII COUNTRY
(1st byte)

SCAN CODE

(2nd byte)

(6 )

6.1. Keyboard (VIII)

INT 16h (BIOS)

Function

Read from the keypad buffer the codes associated with the key or
key combination and advance the buffer pointer to the character
below. If the buffer is empty, wait for a key to be pressed.
Outputs:
AH = Key identifier (SCAN CODE)
AL = ASCII code of the character
Returns the state of the keyboard buffer
Outputs:
ZF = 1 if empty buffer
ZF = 0 if non-empty buffer
AH = Key identifier
AL = ASCII code of character
Pulse status of different keys
Outputs:
Returns in AL the pulse status byte of different keys:
7: Ins, 6: Bloq. Uppercase, 5: Bloq. Numeric, 4: Bloq. Displacement,
3: Alt, 2: Ctrl, 1: Shift Left, 0: Shift Right

AH

00h
and
10h

01h
and
] 11h

02h
and
12h

(6)

6.1. Keyboard (IX)

INT 16h (BIOS)

AH

12h

05h

Function
Press status of different keys
Outputs:
Returns in AH the pulse status byte of different keys:
7: Print Screen, 6: Lock. Uppercase, 5: Bloq. Numeric,
4: Bloq. Offset, 3: Right Alt, 2: Right Ctrl, 1: Left Alt.,
0: Right Ctrl
Type the indicated character in the keyboard buffer.
Inputs:
CH = Key identifier (SCAN CODE)
CL = ASCII code of the character.
Outputs:
AL = 1 if full buffer.

(6)

AH

01h

06h

07h

0Ah

0Bh

6.1. Keyboard (X)

INT 21h (DOS)
Function

Wait to read a character from the keyboard and write it on the screen
Outputs: AL = character typed
Read a character from the keyboard with no output per screen (DL = FFh)
Outputs: AL = typed character if available, AL = 0 if not available
Wait to read a character from the keyboard without writing it by
screen
Outputs: AL = typed character if available
Read keyboard characters without writing them on screen
Input: DS: DX = memory buffer address
The first byte of the buffer must indicate the maximum number of characters
to read (including carriage return)
Outputs: The second byte of the buffer indicates the number of characters
read without including the carriage return. The ASCII codes of the
typed characters are saved from the third byte.
Reads the status of the keyboard
Outputs: AL = FFh if character available, AL = 0 if not available.

(6 )

6.2. Timer (I)

Intel Programmable Interval Timer (8254).
Contains 3 independent 16-bit counters.
Each counter is decremented by one unit in each
clock's falling edge (entry CLK) if its enable signal (GATE input) is activated
.
The output of each counter
(OUT signal) is activated
depending on the mode
in which the counter
] has been programmed
previously.
6 modes of
operation.

CLK 1
GATE 1

CLK 0
GATE 0

8254

CONT 0 [19659002] OUT 0

CONT 1

OUT 1

CLK 2
GATE 2

CONT 2

OUT 2

(6)

6.2. Timer (II)

The timer has 4 I / O ports.
Port 43h (write-only)
Timer control register.
Allows you to define the initial configuration of a meter and
] send a command to store the current counting value
.

40h port (CONT 0)

In the writing modifies the initial counting value of CONT 0.

The counter decreases from this initial value
When reaching zero, the counter can be reloaded with the
same initial value according to the operating mode.

Reading returns the stored value of CONT 0.

Ports 41h (CONT 1) and 42h (CONT 2)

Same behavior as 40h for the other counters

(6)

6.2 . Timer (III)

Control word

The following value is written to port 43h:

SC1 SC0 RW1 RW0 M2

M1

M0

BCD

(6) [19659002] 6.2. Timer (IV)

Control word

The following value is written to port 43h:

SC1 SC0 RW1 RW0 M2

M1

M0

BCD

Counter selection [19659002] SC1

SC0

Action

0
0
1

0
1
0

Select CONT 0
Select CONT 1
Select CONT 2

Configurations of the rest of the control word
applied only to the selected counter.

(6)

6.2. Timer (V)

Control word

The following value is written to port 43h:

SC1 SC0 RW1 RW0 M2

M1

M0

BCD

Memory memorization command current counter value
+ Read / Write configuration on counter

RW1

RW0

Action

0

0

1

1

0

1

0

1

Command for memorizing the current value
(fields M and BCD without effect.)
Reading / Writing in counter port
only affects the low byte.
Read / Write in counter port
only affects high byte.
First read / write in port of
counter affects low byte and second by
high byte.

(6 )

6.2. Timer (VI)

Control word

The following value is written to port 43h:

SC1 SC0 RW1 RW0 M2

M1

M0

BCD

Configuration mode operation

0
0
X
X
1
1

0
0
1
1
0
0

Action

0 Mode 0: Interruption at the end of counting.
1 Mode 1: Programmable monostable.
0 Mode 2: Frequency generator.
1 Mode 3: Square wave generator
0 Mode 4: Strobe pulse initiated by software
1 Mode 5: Strobe pulse initiated by hardware

(6)

6.2. Timer (VII)

Control word

The following value is written to port 43h:

SC1 SC0 RW1 RW0 M2

M1

M0

BCD

Configuration coding counter

BCD

0
1

Action

16-bit binary counter
Four-digit BCD counter

Binary-Coded Decimal (BCD): Every four bits encode
one digit between 0 (0000b) and 9 (1001b).

(6)

6.2. Timer (VIII)

Initial configuration: Control word is sent to
port 43h indicating counter and its initial configuration
(RW ≠ 00b).
Initial count value of a counter:

It is sent to the counter port (40h, 41h or 42h).
Low byte, high byte or low byte followed by
high byte according to control word RW field.

Example: Set counter 2 (SC = 10b) in mode 3
(M = 011b), with binary coding (BCD = 0), and
initialize it to 1234h (RW = 11b).

; Control word: SC | RW | M | BCD

; Send control word

mov to, 10110110b
out 43h, to
mov to, 34h
out 42h, to
mov to, 12h
out 42h, to

; Send low byte

.

Source link



from Nettech Post http://bit.ly/2BYpKGe

No hay comentarios:

Publicar un comentario

Slutty Japanese Babe Toyed And Creamed

Japanese hot babe with big tits gets toyed and creamed. Author: sexualbabe Added: 02/11/2021