Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

I/O Configuration

Muxing Overview

Baochip-1x I/O pads can be configured to numerous functions. The diagram below illustrates the overall scheme for banking.

IO banking overview

The physical I/O pads’ characteristics are configured by registers GPIOPU (for pull-ups) and GPIOCFG (for slew rate, drive strength, and schmitt trigger enable).

A bi-directional “primary” I/O mux connects the pads to any of GPIO, AF1, AF2, and AF3 peripheral logic options. AF1 is further selectable between BIO and AF1 functions using the BIOSEL register at 0x200. When selected, the BIO will override the “output enable” control for the pad.

The BIO pins are designated as BIO[31:0] and they map to ports B/C as BIO[31:0] <-> {PC[15:0],PB[15:0]}.

GPIO Interface

See hardware specifications for the I/O mapping table.

Function 0 is the GPIO base function. PA04–PA07 support an ADC.

Note that when KP (keypad) functions are selected on PF, their function overrides any other setting, and can conflict with PA settings on pads where PF and PA are tied together. This is because the KP functions are available even when the CPU core is powered down and the pinmux is invalid due to the pinmux power domain being turned off.

GPIO Main Features

  • Output states: push-pull or open drain + pull-up/down (GPIOPUx).
  • Output data from output data register (GPIOOUTx).
  • Input states: floating, pull-up/down.
  • Input data to input data register (GPIOINx).
  • Alternate function selection registers (AFSELx).
  • Highly flexible pin multiplexing allows the use of I/O pins as GPIOs or as one of several peripheral functions — see pin map table above.

GPIO Interrupts

  • All ports have external interrupt capability. To use external interrupt lines, the port must be configured in input mode.
  • Configurable interrupt or wakeup (signals from I/Os or peripherals able to generate a pulse). Selectable active trigger edge or level:
    • Rise edge
    • Fall edge
    • High level
    • Low level
  • 8 interrupts (INTCR0INTCR7)
  • NVIC IRQn: 144

GPIO Registers

Base address: 0x5012_F000

Register NameOffsetSizeTypeAccessDefaultDescription
AFSELAL0x000016CRW/R0x00000000Port A pins 0–7 alternate function
AFSELAH0x000416CRW/R0x00000000Port A pins 8–15 alternate function
AFSELBL0x000816CRW/R0x00000000Port B pins 0–7 alternate function
AFSELBH0x000C16CRW/R0x00000000Port B pins 8–15 alternate function
AFSELCL0x001016CRW/R0x00000000Port C pins 0–7 alternate function
AFSELCH0x001416CRW/R0x00000000Port C pins 8–15 alternate function
AFSELDL0x001816CRW/R0x00000000Port D pins 0–7 alternate function
AFSELDH0x001C16CRW/R0x00000000Port D pins 8–15 alternate function
AFSELEL0x002016CRW/R0x00000000Port E pins 0–7 alternate function
AFSELEH0x002416CRW/R0x00000000Port E pins 8–15 alternate function
AFSELFL0x002816CRW/R0x00000000Port F pins 0–7 alternate function
AFSELFH0x002C16CRW/R0x00000000Port F pins 8–15 alternate function
INTCR00x010016CRW/R0x00000000IO interrupt 0 control register
INTCR10x010416CRW/R0x00000000IO interrupt 1 control register
INTCR20x010816CRW/R0x00000000IO interrupt 2 control register
INTCR30x010C16CRW/R0x00000000IO interrupt 3 control register
INTCR40x011016CRW/R0x00000000IO interrupt 4 control register
INTCR50x011416CRW/R0x00000000IO interrupt 5 control register
INTCR60x011816CRW/R0x00000000IO interrupt 6 control register
INTCR70x011C16CRW/R0x00000000IO interrupt 7 control register
INTFR0x012016FRW/R0x00000000IO interrupt flag register
GPIOOUTA0x013016CRW/R0x00000000GPIO output control register — Port A
GPIOOUTB0x013416CRW/R0x00000000GPIO output control register — Port B
GPIOOUTC0x013816CRW/R0x00000000GPIO output control register — Port C
GPIOOUTD0x013C16CRW/R0x00000000GPIO output control register — Port D
GPIOOUTE0x014016CRW/R0x00000000GPIO output control register — Port E
GPIOOUTF0x014416CRW/R0x00000000GPIO output control register — Port F
GPIOOEA0x014816CRW/R0x00000000GPIO output enable control register — Port A
GPIOOEB0x014C16CRW/R0x00000000GPIO output enable control register — Port B
GPIOOEC0x015016CRW/R0x00000000GPIO output enable control register — Port C
GPIOOED0x015416CRW/R0x00000000GPIO output enable control register — Port D
GPIOOEE0x015816CRW/R0x00000000GPIO output enable control register — Port E
GPIOOEF0x015C16CRW/R0x00000000GPIO output enable control register — Port F
GPIOPUA0x016016CRW/R0x0000FFFFGPIO pull-up control register — Port A
GPIOPUB0x016416CRW/R0x0000FFFFGPIO pull-up control register — Port B
GPIOPUC0x016816CRW/R0x0000FFFFGPIO pull-up control register — Port C
GPIOPUD0x016C16CRW/R0x0000FFFFGPIO pull-up control register — Port D
GPIOPUE0x017016CRW/R0x0000FFFFGPIO pull-up control register — Port E
GPIOPUF0x017416CRW/R0x0000FFFFGPIO pull-up control register — Port F
GPIOINA0x017816StatusR0x00000000GPIO input status register — Port A
GPIOINB0x017C16StatusR0x00000000GPIO input status register — Port B
GPIOINC0x018016StatusR0x00000000GPIO input status register — Port C
GPIOIND0x018416StatusR0x00000000GPIO input status register — Port D
GPIOINE0x018816StatusR0x00000000GPIO input status register — Port E
GPIOINF0x018C16StatusR0x00000000GPIO input status register — Port F
BIOSEL0x020032CRW/R0x00000000BIO select register
GPIOCFG_SCHMA0x023016CRW/R0x00000000Input Schmitt trigger enable — Port A
GPIOCFG_SCHMB0x023416CRW/R0x00000000Input Schmitt trigger enable — Port B
GPIOCFG_SCHMC0x023816CRW/R0x00000000Input Schmitt trigger enable — Port C
GPIOCFG_SCHMD0x023C16CRW/R0x00000000Input Schmitt trigger enable — Port D
GPIOCFG_SCHME0x024016CRW/R0x00000000Input Schmitt trigger enable — Port E
GPIOCFG_SCHMF0x024416CRW/R0x00000000Input Schmitt trigger enable — Port F
GPIOCFG_RATCLRA0x024816CRW/R0x00000000Output slew rate control enable — Port A
GPIOCFG_RATCLRB0x024C16CRW/R0x00000000Output slew rate control enable — Port B
GPIOCFG_RATCLRC0x025016CRW/R0x00000000Output slew rate control enable — Port C
GPIOCFG_RATCLRD0x025416CRW/R0x00000000Output slew rate control enable — Port D
GPIOCFG_RATCLRE0x025816CRW/R0x00000000Output slew rate control enable — Port E
GPIOCFG_RATCLRF0x025C16CRW/R0x00000000Output slew rate control enable — Port F
GPIOCFG_DRVSELA0x026032CRW/R0x00000000Output drive current config — Port A
GPIOCFG_DRVSELB0x026432CRW/R0x00000000Output drive current config — Port B
GPIOCFG_DRVSELC0x026832CRW/R0x00000000Output drive current config — Port C
GPIOCFG_DRVSELD0x026C32CRW/R0x00000000Output drive current config — Port D
GPIOCFG_DRVSELE0x027032CRW/R0x00000000Output drive current config — Port E
GPIOCFG_DRVSELF0x027432CRW/R0x00000000Output drive current config — Port F

Register Descriptions

AFSEL — Alternate Function Selection Register

  • Description: I/O pad alternate function selection register
  • Address: 0x0000 + (8 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000

Two bits are assigned per pin. For the low register (AFSELxL), bits [15:0] cover pins 0–7; for the high register (AFSELxH), bits [15:0] cover pins 8–15.

BitsFieldDescription
[1:0] per pinAF select00 = GPIO, 01 = AF1, 10 = AF2, 11 = AF3

BIOSEL — BIO Function Selection Register

  • Description: Connect I/O pad to BIO
  • Address: 0x200
  • Reset value: 0x0000_0000

A bit configured to 1 will cause the BIO to override the AF1 peripheral at that bit. The BIO has 32 bits of I/O mapped as BIO[0:31] = PB[0:15],PC[0:15].

BitsFieldDescription
[31:0]BIO select1 selects BIO

INTCR — IO Interrupt Control Register

  • Description: IO interrupt control register
  • Address: 0x0100 + (4 × X) where X = 0–7
  • Reset value: 0x0000_0000
BitsFieldDescription
[6:0]intselIO pin selection (supports up to 82 IO pins, PA0–PF9)
[8:7]intmodeInterrupt trigger: 00 = rise edge, 01 = fall edge, 10 = high level, 11 = low level
[9]intenInterrupt enable: 1 = enabled, 0 = disabled
[10]wkupeWakeup enable: 1 = enabled, 0 = disabled

INTFR — IO Interrupt Flag Register

  • Description: IO interrupt flag register
  • Address: 0x0120
  • Reset value: 0x0000_0000

Write 1 to a bit to clear it.

BitsFieldDescription
[0]IT7INTCR7 interrupt generated
[1]IT6INTCR6 interrupt generated
[2]IT5INTCR5 interrupt generated
[3]IT4INTCR4 interrupt generated
[4]IT3INTCR3 interrupt generated
[5]IT2INTCR2 interrupt generated
[6]IT1INTCR1 interrupt generated
[7]IT0INTCR0 interrupt generated

GPIOOUT — GPIO Output Control Register

  • Description: GPIO output control register
  • Address: 0x0130 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000
BitsFieldDescription
[15:0]OUTOutput value for each pin in Port x

GPIOOE — GPIO Output Enable Control Register

  • Description: GPIO output enable control register
  • Address: 0x0148 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000
BitsFieldDescription
[15:0]OEOutput enable for each pin in Port x: 1 = output, 0 = input

GPIOPU — GPIO Pull-Up Configuration Register

  • Description: GPIO pull-up configuration register
  • Address: 0x0160 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_FFFF (all pull-ups enabled by default)
BitsFieldDescription
[15:0]PUPull-up enable for each pin in Port x: 1 = pull-up enabled

GPIOIN — GPIO Input Status Register

  • Description: GPIO input status register (read-only)
  • Address: 0x0178 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000
BitsFieldDescription
[15:0]INCurrent input state for each pin in Port x

GPIOCFG_SCHM — Input Schmitt Trigger Enable Register

  • Description: GPIO input Schmitt trigger enable register
  • Address: 0x0230 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000
BitsFieldDescription
[15:0]SCHMSchmitt trigger enable for each pin in Port x: 1 = enabled

GPIOCFG_RATCLR — Output Slew Rate Control Register

  • Description: GPIO output slew rate control enable register
  • Address: 0x0248 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000
BitsFieldDescription
[15:0]RATCLRSlew rate control enable for each pin in Port x: 1 = enabled

GPIOCFG_DRVSEL — Output Drive Current Configuration Register

  • Description: GPIO output drive current configuration register
  • Address: 0x0260 + (4 × X) where X = 0–5 (Ports A–F)
  • Reset value: 0x0000_0000

Two bits are assigned per pin (32-bit register, covering all 16 pins per port).

Bits [1:0] per pinDrive current
2'b002 mA
2'b104 mA
2'b018 mA
2'b1112 mA