31.5.15 I/O Lines Programming Example

The following table provides an example of programming I/O lines to obtain these configuration:

  • 4-bit output port on I/O lines 0 to 3 (must be written in a single write operation), open drain, with pull-up resistor
  • Four output signals on I/O lines 4 to 7 (for example, to drive LEDs) driven high and low, no pull-up resistor, no pull-down resistor
  • Four input signals on I/O lines 8 to 11 (for example, to read push-button states), with pull-up resistors, glitch filters, and input change interrupts
  • Four input signals on I/O line 12 to 15 to read an external device status (polled, thus no input change interrupt), no pull-up resistor, no glitch filter
  • I/O lines 16 to 19 assigned to peripheral A functions with pull-up resistor
  • I/O lines 20 to 23 assigned to peripheral B functions with pull-down resistor
  • I/O lines 24 to 27 assigned to peripheral C with input change interrupt, no pull-up resistor and no pull-down resistor
  • I/O lines 28 to 31 assigned to peripheral D, no pull-up resistor and no pull-down resistor
    Table 31-3. Programming Example
    RegisterValue to be Written
    PIO_PER0x0000_FFFF
    PIO_PDR0xFFFF_0000
    PIO_OER0x0000_00FF
    PIO_ODR0xFFFF_FF00
    PIO_IFER0x0000_0F00
    PIO_IFDR0xFFFF_F0FF
    PIO_SODR0x0000_0000
    PIO_CODR0x0FFF_FFFF
    PIO_IER0x0F00_0F00
    PIO_IDR0xF0FF_F0FF
    PIO_MDER0x0000_000F
    PIO_MDDR0xFFFF_FFF0
    PIO_PUDR0xFFF0_00F0
    PIO_PUER0x000F_FF0F
    PIO_PPDDR0xFF0F_FFFF
    PIO_PPDER0x00F0_0000
    PIO_ABCDSR00xF0F0_0000
    PIO_ABCDSR10xFF00_0000
    PIO_OWER0x0000_000F
    PIO_OWDR0x0FFF_FFF0