nRF5 SDK v14.2.0
PPI Example

The Programmable Peripheral Interconnect (PPI) Example uses the PPI module to communicate between three timers.

Timer 0 is configured to generate an interrupt every 100 milliseconds to increment the counter value. Next, this counter value is passed through the UART port and can be observed with a COM listener like, for example, PuTTY.

Timer 1 generates events every even second, thus at 2, 4, 6, 8, ... seconds. These events trigger a stop task for Timer 0.

Timer 2 generates events every odd second, thus at 3, 5, 7, 9 ... seconds. Timer 2 is started one second after Timer 1, hence it generates events starting from the third second. These events trigger a start task for Timer 0. The start and stop tasks are triggered using PPI.

When the application starts, for the first second the timers are synchronizing. Next, the counter value of Timer 0 increases every 100 milliseconds for the first second. Then, Timer 1 creates an event that is passed through PPI, generating a stop task for Timer 0. Therefore, Timer 0 stops. After one second, Timer 2 creates an event that is passed through PPI, generating a start task for Timer 0. Timer 0 starts again, and the counter value increases again every 100 milliseconds until it is stopped again by Timer 1 after one second.

ppi_example.svg

The application starts with configuration of the three timers:

The PPI is configured to make Timer 0 stop and start when Timer 1 and Timer 2, respectively, generate events. The main loop prints the counter value every 100 milliseconds when Timer 0 is active. Counter value is not printed during the first second of application execution because this time is utilized to start Timer 2. As a result, counter value equals 10, not 20, when Timer 0 is stopped for the first time.

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

Testing

Test the PPI Example application by performing the following steps:

  1. Compile and program the application.
  2. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  3. Check the output and observe that the counting stops and starts every second.

Documentation feedback | Developer Zone | Subscribe | Updated