nRF51 SDK: GPIOTE Example

| nRF51 SDK

- Home
- Related Pages
- API Reference
- Data Structures

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

The GPIOTE Example shows the usage of GPIOTE peripheral by toggling a LED. We use TIMER0 to generate 'EVENT_COMPARE0' event every 200 milliseconds. This will also clear the TIMER0 internal clock. This event is passed through PPI peripheral to generate a task. This task is used by GPIOTE (task mode) to toggle the pin. This means that every time we have EVENT_COMPARE event, the GPIO pin toggles automatically, which can only be achieved using the GPIOTE peripheral. It uses the hardware delivered in the nRF51822 Development Kit.

[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  |  |
    * |                                                            ---------------   |
    *  ------------------------------------------------------------------------------
    *
    *

The application starts with configuring the GPIOTE output pin to toggle on a GPIOTE task. Timer0 is configured to generate events every 200ms, and the PPI channel is configured to connect the timer event to the GPIOTE task.

# Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

LED assignments:

- LED 0 is used to show the toggling done by the GPIOTE task.

# Testing

The GPIOTE Example Application can be tested as follows:

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