Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
mikrocont / MC68HC705C8A.pdf
Источник:
Скачиваний:
59
Добавлен:
06.01.2022
Размер:
2.49 Mб
Скачать

Parallel Input/Output (I/O)

Port B

7.4 Port B

Port B is an 8-bit, general-purpose, bidirectional I/O port. Port B pins can also be configured to function as external interrupts. The port B pullup devices are enabled in mask option register 1 (MOR1). See 9.5.2 Mask Option Register 1 and 4.3.3 Port B Interrupts.

7.4.1 Port B Data Register

The port B data register (PORTB) shown in Figure 7-4 contains a data latch for each of the eight port B pins.

Address: $0001

 

 

 

 

 

 

 

 

Bit 7

6

5

4

3

2

1

Bit 0

 

 

 

 

 

 

 

 

Read:

PB7

PB6

PB5

PB4

PB3

PB2

PB1

PB0

Write:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reset:

 

 

Unaffected by reset

 

 

 

Figure 7-4. Port B Data Register (PORTB)

PB7–PB0 — Port B Data Bits

These read/write bits are software programmable. Data direction of each bit is under the control of the corresponding bit in data direction register B. Reset has no effect on port B data.

MC68HC705C8A —

Rev. 3

Technical Data

 

 

 

MOTOROLA

Parallel Input/Output (I/O)

81

Parallel Input/Output (I/O)

7.4.2 Data Direction Register B

The contents of data direction register B (DDRB) shown in Figure 7-5 determine whether each port B pin is an input or an output. Writing a logic 1 to a DDRB bit enables the output buffer for the associated port B pin; a logic 0 disables the output buffer. A reset clears all DDRB bits, configuring all port B pins as inputs. If the pullup devices are enabled by mask option, setting a DDRB bit to a logic 1 turns off the pullup device for that pin.

Address:

$0005

 

 

 

 

 

 

 

 

Bit 7

6

5

4

3

2

1

Bit 0

Read:

 

 

 

 

 

 

 

 

DDRB7

DDRB6

DDRB5

DDRB4

DDRB3

DDRB2

DDRB1

DDRB0

Write:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reset:

0

0

0

0

0

0

0

0

Figure 7-5. Data Direction Register B (DDRB)

DDRB7–DDRB0 — Port B Data Direction Bits

These read/write bits control port B data direction. Reset clears bits

DDRB7–DDRB0.

1 = Corresponding port B pin configured as output

0 = Corresponding port B pin configured as input

NOTE: Avoid glitches on port B pins by writing to the port B data register before changing DDRB bits from logic 0 to logic 1.

Technical Data

 

MC68HC705C8A — Rev. 3

 

 

 

82

Parallel Input/Output (I/O)

MOTOROLA

Parallel Input/Output (I/O)

Port B

7.4.3 Port B Logic

Figure 7-6 shows the port B I/O logic.

VDD

 

 

 

PBPU7

 

 

 

FROM MOR1

 

READ $0005

 

 

 

WRITE $0005

DATA DIRECTION

 

 

 

 

 

RESET

REGISTER B

 

DATA BUS

BIT DDRB7

 

 

 

WRITE $0001

PORT B DATA

 

INTERNAL

REGISTER

PB7

 

 

BIT PB7

 

 

 

 

 

READ $0001

 

 

 

IRQ

 

 

 

FROM OPTION

 

 

 

REGISTER

 

 

 

VDD

 

 

 

 

 

EXTERNAL

 

D

Q

INTERRUPT

 

IRQ

 

REQUEST

FROM OTHER

LATCH

 

 

 

 

 

PORT B PINS

C

Q

 

 

R

 

 

 

 

 

I BIT

 

 

 

FROM CCR

IRQ

 

 

 

RESET

EXTERNAL INTERRUPT VECTOR FETCH

Figure 7-6. Port B I/O Logic

MC68HC705C8A —

Rev. 3

Technical Data

 

 

 

MOTOROLA

Parallel Input/Output (I/O)

83

Parallel Input/Output (I/O)

When a port B pin is programmed as an output, reading the port bit reads the value of the data latch and not the voltage on the pin itself. When a port B pin is programmed as an input, reading the port bit reads the voltage level on the pin. The data latch can always be written, regardless of the state of its DDRB bit.

Table 7-2. Port B Pin Functions

DDRB Bit

I/O Pin Mode

Accesses to DDRB

Accesses to PORTB

 

 

 

Read/Write

Read

Write

 

 

 

 

 

 

 

0

Input, Hi-Z(1)

DDRB7–DDRB0

Pin

PB7–PB0(2)

1

Output

DDRB7–DDRB0

PB7–PB0

PB7–PB0

 

 

 

 

 

1.Hi-Z = high impedance

2.Writing affects data register but does not affect input.

NOTE: To avoid excessive current draw, tie all unused input pins to VDD or VSS, or for I/O pins change to outputs by writing to DDRB in user code as early as possible.

Technical Data

 

MC68HC705C8A — Rev. 3

 

 

 

84

Parallel Input/Output (I/O)

MOTOROLA

Соседние файлы в папке mikrocont