PPI trace

The PPI trace sample shows how to trace hardware events on GPIO pins. It uses the PPI trace module.

Overview

The sample initializes trace pins to observe the following hardware events:

  • RTC Compare event (NRF_RTC_EVENT_COMPARE_0)

  • RTC Tick event (NRF_RTC_EVENT_TICK)

  • Low frequency clock (LFCLK) Started event (NRF_CLOCK_EVENT_LFCLKSTARTED)

  • Radio activity during Bluetooth advertising (available only for Bluetooth capable devices)

The sample sets up a Counter to generate an NRF_RTC_EVENT_COMPARE_0 event every 50 ms. Initially, RTC runs on RC low frequency (lower precision) as clock source. When the crystal is ready, it switches seamlessly to crystal (precise) as clock source. When the low-frequency crystal is ready, an NRF_CLOCK_EVENT_LFCLKSTARTED event is generated.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160

The sample also requires a logic analyzer.

Building and running

This sample can be found under samples/debug/ppi_trace in the nRF Connect SDK folder structure.

See Building and programming a sample application for information about how to build and program the application.

Testing

After programming the sample to your board, test it by performing the following steps:

  1. Connect a logic analyzer to the pins that are used for tracing. Check the sample configuration for information about which pins are used. To do so in SEGGER Embedded Studio, select Project -> Configure nRF Connect SDK Project and navigate to PPI trace pins configuration.

  2. Observe that:

    • The pin that is tracing the RTC Tick event is toggling with a frequency of approximately 32 kHz.

    • The pin that is tracing the RTC Compare event is toggling approximately every 50 ms.

    • The pin that is tracing the LFCLK Started event is set at some point.

  3. Measure the typical time between two consecutive toggles of the pin that is tracing the RTC Compare event, before and after the LFCLK Started event is generated. Observe that the precision increases when the low-frequency crystal is started.

  4. Observe periodical radio activity during Bluetooth advertising.

Dependencies

This sample uses the following nRF Connect SDK subsystems:

In addition, it uses the following Zephyr libraries: