| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
GPIOTE Example

The GPIOTE Example shows how to use the GPIOTE peripheral by toggling a LED.

The application starts with configuring the GPIOTE output pin to toggle on a GPIOTE task. Timer 0 is then configured to generate events every 200 milliseconds. The events are passed through the PPI peripheral to generate tasks, which are then used by GPIOTE (in task mode) to toggle the GPIO pin. This means that every time there is an EVENT_COMPARE event, the GPIO pin toggles automatically, which can only be achieved using the GPIOTE peripheral.

The task flow is as follows:

[TIMER0]->EVENT_COMPARE->[PPI]->GPIOTE_TASK_OUT->[GPIOTE]->toggle_pin

    *          ----------------                       --------------------------
    *  -Start-|    Timer0      |                     |   EEP |    PPI    |  TEP |-------
    *  ------>|  CC[0] = 200ms |-----Timer0_Event--->|       | Channel 0 |      |       |
    * |        ----------------                       --------------------------        |
    * |                                                                                 |
    * |    -----------------------------------------------------------------------------
    * |   |
    * |   |                 -----------------                      ---------------
    * |    ---------TASK-->|     GPIO_TE     |-->Toggled_Output-->|  LED toggling |--
    * |                     -----------------                     |  every 200ms  |  |
    * |                                                            ---------------   |
    *  ------------------------------------------------------------------------------
    *
    *

# Setup

You can find the source code and the project file of the example in the following folder: `<InstallFolder>\examples\peripheral\gpiote`

LED assignments:

- LED 1 shows the toggling done by the GPIOTE task.

# Testing

Test the GPIOTE Example application by performing the following steps:

1. Compile and program the application.
2. Observe that LED 1 toggles at the rate of 200 milliseconds.