Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
162
Добавлен:
01.03.2016
Размер:
3.56 Mб
Скачать

General purpose I/O ports (GPIO)

RM0016

 

 

Figure 24. GPIO block diagram

ALTERNATE

 

 

P-BUFFER

1

 

(see table below)

OUTPUT

 

 

 

 

 

PAD

 

 

 

 

 

ALTERNATE

0

VDD

 

 

 

 

 

ENABLE

 

 

 

 

 

 

 

PULL-UP

 

OUTPUT

 

 

(see table below)

 

 

 

 

 

ODR REGISTER

 

 

VDD

 

 

 

 

 

DDR REGISTER

 

PULL-UP

 

 

 

CONDITION

 

 

 

 

 

 

 

 

 

PIN

 

CR1 REGISTER

 

 

 

DATA

 

 

SLOPE

 

 

 

CONTROL

 

BUS

CR2 REGISTER

 

PROTECTION

 

N-BUFFER

 

DIODES

 

 

 

 

 

 

 

 

 

(see table below)

 

ADC_TDR REGISTER

 

 

 

 

INPUT

 

 

 

 

IDR REGISTER

 

 

 

 

(Read only)

 

 

 

 

 

 

CMOS

 

 

 

 

SCHMITT

 

 

 

 

TRIGGER

 

ALTERNATE FUNCTION

 

 

 

INPUT TO ON-CHIP

 

 

 

PERIPHERAL

 

 

 

EXTERNAL

 

 

 

 

 

 

 

FROM

 

 

INTERRUPT

 

 

 

 

 

OTHER

 

 

 

 

 

TO INTERRUPT

BITS

CONTROLLER

ANALOG

 

INPUT TO A/D CONVERTER

Note: The output stage is disabled when the analog input is selected.

11.3Port configuration and usage

An output data register (ODR), pin input register (IDR), data direction register (DDR) are always associated with each port.

The control register 1 (CR1) and control register 2 (CR2) allow input/output options. An I/O pin is programmed using the corresponding bits in the DDR, ODR, CR1 and CR2 registers.

Bit n in the registers corresponds to pin n of the Port.

The various configurations are summarized in Table 21.

106/454

Doc ID 14587 Rev 9

RM0016

 

 

 

 

 

General purpose I/O ports (GPIO)

 

 

 

 

 

 

 

 

 

 

 

 

Table 21.

I/O port configuration summary

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mode

DDR

CR1

CR2

Function

Pull-up

P-buffer

Diodes

 

 

 

 

bit

 

bit

bit

to VDD

to VSS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

0

Floating without

Off

 

 

 

 

 

 

interrupt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Input

0

 

1

0

Pull-up without

On

Off

 

 

 

 

interrupt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

0

1

Floating with interrupt

Off

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

1

1

Pull-up with interrupt

On

 

(1)

 

 

 

 

 

 

 

 

 

 

On

 

 

 

1

 

0

0

Open drain output

 

Off

 

On

 

 

 

 

 

 

 

 

 

 

 

 

1

 

1

0

Push-pull output

Off

On

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

0

1

Open drain output, fast

 

Off

 

 

 

 

 

mode

 

 

 

 

Output

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

1

1

Push-pull, fast mode

Off

On

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

True open drain (on

 

 

Not im-

 

 

 

1

 

x

x

Not implemented

plemented

 

 

 

 

specific pins)

 

 

 

 

 

 

 

 

 

(2)

 

 

 

 

 

 

 

 

 

 

 

 

1.In 3.6 V and 5 V tolerant I/Os, protection diode to VDD is not implemented.

2.The diode connected to VDD is not implemented in true open drain pads. A local protection between the pad and VOL is implemented to protect the device against positive stress.

11.3.1Input modes

Clearing the DDRx bit selects input mode. In this mode, reading a IDR bit returns the digital value of the corresponding I/O pin.

Refer to Section 11.7: Input mode details on page 108 for information on analog input, external interrupts and Schmitt trigger enable/disable.

As shown in Table 21, four different input modes can be theoretically be configured by software: floating without interrupt, floating with interrupt, pull-up without interrupt or pull-up with interrupt. However in practice, not all ports have external interrupt capability or pull-ups. You should refer to the datasheet pin-out description for details on the actual hardware capability of each port.

11.3.2Output modes

Setting the DDRx bit selects output mode. In this mode, writing to the ODR bits applies a digital value to the I/O through the latch. Reading IDR bit returns the digital value from the corresponding I/O pin. Using the CR1, CR2 registers, different output modes can be configured by software: Push-pull output, Open-drain output.

Refer to Section 11.8: Output mode details on page 109 for more information.

Doc ID 14587 Rev 9

107/454

Соседние файлы в папке Минимум документации STM8_1