21.5.10 Input Edge/Level Interrupt

Each I/O group can be programmed to generate an interrupt when it detects an edge or a level on an I/O line. The Input Edge/Level interrupts are controlled by writing the PIO Interrupt Enable Register (PIO_IERx) and the PIO Interrupt Disable Register (PIO_IDRx), which enable and disable the input change interrupt respectively by setting and clearing the corresponding bit in the PIO Interrupt Mask Register (PIO_IMRx). For the Privileged-Access mode I/O lines, the Input Edge/Level interrupts are controlled by writing PIO_P_IERx and PIO_P_IDRx, which enable and disable input change interrupts, respectively, by setting and clearing the corresponding bit in the PIO_P_IMRx. As input change detection is possible only by comparing two successive samplings of the input of the I/O line, the PIO Controller clock must be enabled. The Input Change interrupt is available regardless of the configuration of the I/O line, i.e., configured as an input only, controlled by the PIO Controller or assigned to a peripheral function.

Each I/O group can generate a User-Access IO interrupt and a Privileged-Access IO interrupt according to the access level of the I/O line which triggers the interrupt.

According to the EVTSEL field value in PIO_CFGRx or PIO_P_CFGRx in case of a Privileged-Access mode I/O line, the interrupt signal of the I/O group x can be generated on the following occurrence:

  • PIO_(P_)CFGRx.EVTSELy = 0: The interrupt signal of the I/O group x is generated on the I/O line y falling edge detection (assuming that PIO_(P_)IMRx[y] = 1).
  • PIO_(P_)CFGRx.EVTSELy = 1: The interrupt signal of the I/O group x is generated on the I/O line y rising edge detection (assuming that PIO_(P_)IMRx[y] = 1).
  • PIO_(P_)CFGRx.EVTSELy = 2: The interrupt signal of the I/O group x is generated on the I/O line y both rising and falling edge detection (assuming that PIO_(P_)IMRx[y] = 1).
  • PIO_(P_)CFGRx.EVTSELy = 3: The interrupt signal of the I/O group x is generated on the I/O line y low level detection (assuming that PIO_(P_)IMRx[y] = 1).
  • PIO_(P_)CFGRx.EVTSELy = 4: The interrupt signal of the I/O group x is generated on the I/O line y high level detection (assuming that PIO_(P_)IMRx[y] = 1).

By default, the interrupt can be generated at any time a falling edge is detected on the input.

When an input edge or level is detected on an I/O line, the corresponding bit in the PIO Interrupt Status Register (PIO_ISRx), or in the PIO Privilege Interrupt Status Register (PIO_P_ISRx) if the I/O line access is privileged, is set.

For a User-Access mode I/O line, if the corresponding bit in PIO_IMRx is set, the User-Access mode I/O interrupt line of the I/O group x is asserted. For a Privileged-Access mode I/O line, if the corresponding bit in PIO_P_IMRx is set, the Privileged-Access mode I/O interrupt line of the I/O group x is asserted.

When the software reads PIO_ISRx, all the User-Access mode interrupts of the I/O group x are automatically cleared. When the software reads PIO_P_ISRx, all the interrupt sources related to Privileged-Access mode I/O lines of the I/O group x are automatically cleared. This signifies that all the interrupts that are pending when PIO_ISRx or PIO_P_ISRx are read must be handled. When an interrupt is enabled on a “level”, the interrupt is generated as long as the interrupt source is not cleared, even if some read accesses in PIO_ISRx or PIO_P_ISRx are performed.

Figure 21-6. Event Detector on Input Lines

Example of interrupt generation on following lines:

  • Rising edge on the Privileged-Access PIO line 0 of the I/O group 0 (PIOA)
  • Low-level edge on the Privileged-Access PIO line 1of the I/O group 0 (PIOA)
  • Rising edge on the Privileged-Access PIO line 2 of the I/O group 0 (PIOA)
  • High-level on the Privileged-Access PIO line 3 of the I/O group 0 (PIOA)
  • Low-level on the User-Access PIO line 4 of the I/O group 0 (PIOA)
  • High-level on the Privileged-Access PIO line 0 of the I/O group 1 (PIOB)
  • Falling edge on the Privileged-Access PIO line 1 of the I/O group 1 (PIOB)
  • Rising edge on the Privileged-Access PIO line 2 of the I/O group 1 (PIOB)
  • Any edge on the other User-Access lines of the I/O group 1 (PIOB)

The table below details the required configuration for this example.

Table 21-2. Configuration for Example Interrupt Generation
ConfigurationName
PIOA: I/O Line Security Level

Define the I/O lines 0 to 3 of the PIOA as Privileged-Access by writing 32’h0000_000F in the PIO_P_SIO_PAR0 (offset 0x1034)

Define the I/O lines 4 of the PIOA as User-Access by writing 32’h0000_0010 in the PIO_P_SIO_UAR0 (offset 0x1030)

PIOA: Interrupt Mode

Enable interrupt sources for lines 0 to 3 of PIOA by writing 32’h0000_000F in PIO_P_IER0 (offset 0x1020)

Enable interrupt source for the line 4 of PIOA by writing 32’h0000_0010 in PIO_IER0 (offset 0x20)

PIOA: Event Selection

Configure Rising Edge detection for Privileged-Access lines 0 and 2:

Write 32’h0000_0005 in PIO_P_MSKR0 (offset 0x1000)

Write 32’h0100_0000 in PIO_P_CFGR0 (offset 0x1004)

Configure Low Level detection for Privileged-Access line 1:

Write 32’h0000_0002 in PIO_P_MSKR0 (offset 0x1000)

Write 32’h0300_0000 in PIO_P_CFGR0 (offset 0x1004)

Configure High Level detection for Privileged-Access line 3:

Write 32’h0000_0008 in PIO_P_MSKR0 (offset 0x1000)

Write 32’h0400_0000 in PIO_P_CFGR0 (offset 0x1004)

Configure Low Level detection for User-Access line 4:

Write 32’h0000_0010 in PIO_MSKR0 (offset 0x0)

Write 32’h0300_0000 in PIO_CFGR0 (offset 0x4)

PIOB: I/O Line Security Level

Define the I/O lines 0 to 2 of the PIOB as Privileged-Access by writing 32’h0000_0007 in the PIO_P_SIO_PAR1 (offset 0x1074)

Define the other I/O lines of the PIOB as User-Access by writing 32’hFFFF_FFF8 in the PIO_P_SIO_UAR1 (offset 0x1070)

PIOB: Interrupt Mode

Enable interrupt sources for lines 0 to 2 of PIOB by writing 32’h0000_0007 in PIO_P_IER1 (offset 0x1060)

Enable interrupt sources for all other lines of PIOB by writing 32’hFFFF_FFF8 in PIO_IER1 (offset 0x60)

PIOB: Event Selection

Configure High Level detection for Privileged-Access line 0:

Write 32’h0000_0001 in PIO_P_MSKR1 (offset 0x1040)

Write 32’h0400_0000 in PIO_P_CFGR1 (offset 0x1044)

Configure Falling Edge detection for Privileged-Access line 1:

Write 32’h0000_0002 in PIO_P_MSKR1 (offset 0x1040)

Write 32’h0000_0000 in PIO_P_CFGR1 (offset 0x1044)

Configure Rising Edge detection for Privileged-Access line 2:

Write 32’h0000_0004 in PIO_P_MSKR1 (offset 0x1040)

Write 32’h0100_000 in PIO_P_CFGR1 (offset 0x1044)

Configure Low Level detection for User-Access lines:

Write 32’hFFFF_FFF8 in PIO_MSKR1 (offset 0x40)

Write 32’h0200_000 in PIO_CFGR1 (offset 0x44)

Figure 21-7. Input Change Interrupt Timings When No Additional Interrupt Modes