2.19. GPIO
Hier geht es um die Programmierung der GPIO's
Inhalt dieser Seite[Bearbeiten | Quelltext bearbeiten]
2.19.1. Overview
2.19.2. Function Select
2.19.3. Interrupts
2.19.4. Pads
2.19.5. Software Examples
2.19.6. List of Registers
Overview[Bearbeiten | Quelltext bearbeiten]
Der RP2040 hat 36 multifunktionale General Purpose Input / Output (GPIO) Pins, aufgeteilt in zwei Bänke.
Davon stehen 30 als User-Bank GPIO0 - GPIO29 zur allgemeinen Verwendung zur Verfügung. Die übrigen 6 bilden die QSPI Schnittstelle zur Ansteuerung von externen Speichern.
Alle GPIOs unterstützen digitale Ein- und Ausgänge, aber GPIO26 bis GPIO29 können auch als Eingänge für den Analog-Digital-Wandler (ADC) des Chips verwendet werden.
Jeder GPIO kann direkt von der auf den Prozessoren laufenden Software oder von einer Reihe anderer Funktionsblöcke gesteuert werden.
Die Benutzer-GPIO-Bank unterstützt die folgenden Funktionen:
- Software control via SIO (Single-Cycle IO) - Section 2.3.1.2, “GPIO Control”
- Programmable IO (PIO) - Chapter 3, PIO
- 2 × SPI - Section 4.4, “SPI”
- 2 × UART - Section 4.2, “UART”
- 2 × I2C (two-wire serial interface) - Section 4.3, “I2C”
- 8 × two-channel PWM - Section 4.5, “PWM”
- 2 × external clock inputs - Section 2.15.2.3, “External Clocks”
- 4 × general purpose clock output - Section 2.15, “Clocks”
- 4 × input to ADC - Section 4.9, “ADC and Temperature Sensor”
- USB VBUS management - Section 4.1.2.8, “VBUS Control”
- External interrupt requests, level or edge-sensitive
Die QSPI Bank unterstützt die folgenden Funktionen:
- Software control via SIO (Single-Cycle IO) - Section 2.3.1.2, “GPIO Control”
- Flash execute in place (XIP) - Section 2.6.3, “Flash”
Function Select[Bearbeiten | Quelltext bearbeiten]
Die jedem GPIO zugewiesene Funktion wird durch Schreiben in das FUNCSEL-Feld im CTRL-Register des GPIO ausgewählt.
Siehe GPIO0_CTRL als Beispiel.
Die für jeden IO verfügbaren Funktionen sind in Tabelle 279 und Tabelle 281 aufgeführt.
GPIO | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 |
---|---|---|---|---|---|---|---|---|---|
0 | SPI0 RX | UART0 TX | I2C0 SDA | PWM0 A | SIO | PIO0 | PIO1 | USB OVCUR DET | |
1 | SPI0 CSn | UART0 RX | I2C0 SCL | PWM0 B | SIO | PIO0 | PIO1 | USB VBUS DET | |
2 | SPI0 SCK | UART0 CTS | I2C1 SDA | PWM1 A | SIO | PIO0 | PIO1 | USB VBUS EN | |
3 | SPI0 TX | UART0 RTS | I2C1 SCL | PWM1 B | SIO | PIO0 | PIO1 | USB OVCUR DET | |
4 | SPI0 RX | UART1 TX | I2C0 SDA | PWM2 A | SIO | PIO0 | PIO1 | USB VBUS DET | |
5 | SPI0 CSn | UART1 RX | I2C0 SCL | PWM2 B | SIO | PIO0 | PIO1 | USB VBUS EN | |
6 | SPI0 SCK | UART1 CTS | I2C1 SDA | PWM3 A | SIO | PIO0 | PIO1 | USB OVCUR DET | |
7 | SPI0 TX | UART1 RTS | I2C1 SCL | PWM3 B | SIO | PIO0 | PIO1 | USB VBUS DET | |
8 | SPI1 RX | UART1 TX | I2C0 SDA | PWM4 A | SIO | PIO0 | PIO1 | USB VBUS EN | |
9 | SPI1 CSn | UART1 RX | I2C0 SCL | PWM4 B | SIO | PIO0 | PIO1 | USB OVCUR DET | |
10 | SPI1 SCK | UART1 CTS | I2C1 SDA | PWM5 A | SIO | PIO0 | PIO1 | USB VBUS DET | |
11 | SPI1 TX | UART1 RTS | I2C1 SCL | PWM5 B | SIO | PIO0 | PIO1 | USB VBUS EN | |
12 | SPI1 RX | UART0 TX | I2C0 SDA | PWM6 A | SIO | PIO0 | PIO1 | USB OVCUR DET | |
13 | SPI1 CSn | UART0 RX | I2C0 SCL | PWM6 B | SIO | PIO0 | PIO1 | USB VBUS DET | |
14 | SPI1 SCK | UART0 CTS | I2C1 SDA | PWM7 A | SIO | PIO0 | PIO1 | USB VBUS EN | |
15 | SPI1 TX | UART0 RTS | I2C1 SCL | PWM7 B | SIO | PIO0 | PIO1 | USB OVCUR DET | |
16 | SPI0 RX | UART0 TX | I2C0 SDA | PWM0 A | SIO | PIO0 | PIO1 | USB VBUS DET | |
17 | SPI0 CSn | UART0 RX | I2C0 SCL | PWM0 B | SIO | PIO0 | PIO1 | USB VBUS EN | |
18 | SPI0 SCK | UART0 CTS | I2C1 SDA | PWM1 A | SIO | PIO0 | PIO1 | USB OVCUR DET | |
19 | SPI0 TX | UART0 RTS | I2C1 SCL | PWM1 B | SIO | PIO0 | PIO1 | USB VBUS DET | |
20 | SPI0 RX | UART1 TX | I2C0 SDA | PWM2 A | SIO | PIO0 | PIO1 | CLOCK GPIN0 | USB VBUS EN |
21 | SPI0 CSn | UART1 RX | I2C0 SCL | PWM2 B | SIO | PIO0 | PIO1 | CLOCK GPOUT0 | USB OVCUR DET |
22 | SPI0 SCK | UART1 CTS | I2C1 SDA | PWM3 A | SIO | PIO0 | PIO1 | CLOCK GPIN1 | USB VBUS DET |
23 | SPI0 TX | UART1 RTS | I2C1 SCL | PWM3 B | SIO | PIO0 | PIO1 | CLOCK GPOUT1 | USB VBUS EN |
24 | SPI1 RX | UART1 TX | I2C0 SDA | PWM4 A | SIO | PIO0 | PIO1 | CLOCK GPOUT2 | USB OVCUR DET |
25 | SPI1 CSn | UART1 RX | I2C0 SCL | PWM4 B | SIO | PIO0 | PIO1 | CLOCK GPOUT3 | USB VBUS DET |
26 | SPI1 SCK | UART1 CTS | I2C1 SDA | PWM5 A | SIO | PIO0 | PIO1 | USB VBUS EN | |
27 | SPI1 TX | UART1 RTS | I2C1 SCL | PWM5 B | SIO | PIO0 | PIO1 | USB OVCUR DET | |
28 | SPI1 RX | UART0 TX | I2C0 SDA | PWM6 A | SIO | PIO0 | PIO1 | USB VBUS DET | |
29 | SPI1 CSn | UART0 RX | I2C0 SCL | PWM6 B | SIO | PIO0 | PIO1 | USB VBUS EN |
Für jeden GPIO kann jeweils nur eine Funktion ausgewählt werden. Ebenso sollte jeder Peripherieeingang (z.B. UART0 RX) nur
jeweils an einem GPIO ausgewählt werden.
Wenn derselbe Peripherieeingang mit mehreren GPIOs verbunden ist, sieht das Peripheriegerät das logische ODER dieser GPIO-Eingänge.
Function Name | Description |
---|---|
SPIx | Verbinden Sie eine der internen PL022 SPI-Peripheriegeräte mit GPIO |
UARTx | Verbinden Sie einen der internen PL011 UART-Peripheriegeräte mit GPIO |
I2Cx | Verbinden Sie einen der internen DW I2C-Peripheriegeräte mit GPIO |
PWMx A/B | Schließen Sie eine PWM-Scheibe an GPIO an. Es gibt acht PWM-Slices mit jeweils zwei Ausgangskanälen (A/B). Der B-Pin kann auch als Eingang für die Messung von Frequenz und Tastverhältnis verwendet werden. |
SIO | Software-Steuerung von GPIO über den Single-Cycle-IO-Block (SIO). Die SIO-Funktion (F5) muss ausgewählt werden, damit die Prozessoren einen GPIO ansteuern können, aber der Eingang ist immer angeschlossen, so dass die Software den Zustand der GPIOs jederzeit überprüfen kann. |
PIOx | Schließen Sie einen der programmierbaren IO-Blöcke (PIO) an GPIO an. PIO kann eine Vielzahl von Schnittstellen implementieren und verfügt über eine eigene interne Pin-Mapping-Hardware, die eine flexible Platzierung digitaler Schnittstellen an GPIOs der Benutzerbank ermöglicht. Die PIO-Funktion (F6, F7) muss für PIO ausgewählt werden, um einen GPIO anzusteuern, aber der Eingang ist immer verbunden, so dass die PIOs immer den Zustand aller Pins sehen können. |
CLOCK GPINx | Allzweck-Takteingänge. Kann an eine Reihe von internen Taktdomänen auf dem
RP2040 geroutet werden, z.B. um einen 1Hz-Takt für die RTC bereitzustellen, oder kann an einen internen Frequenzzähler angeschlossen werden. |
CLOCK GPOUTx | Allzweck-Taktausgänge. Kann eine Reihe von internen Takten auf GPIOs treiben, mit optionaler ganzzahliger Teilung. |
USB OVCUR DET/VBUS DET/VBUS EN | USB-Leistungssteuerungssignale an/von dem internen USB-Controller |
Interrupts[Bearbeiten | Quelltext bearbeiten]
Pads[Bearbeiten | Quelltext bearbeiten]
Software Examples[Bearbeiten | Quelltext bearbeiten]
List of Registers[Bearbeiten | Quelltext bearbeiten]
[Bearbeiten | Quelltext bearbeiten]
zurück zu The_Core_-_RP2040
zurück zu Raspberry_Pi_Pico_-_RP2040
zurück zu Microcontroller
Zurück zur Hauptseite