16.9. GPTMR EXTERNAL COUNTER MODE

16.9.1. Overview

The sample demonstrates the GPTMR external counting mode function. The counter increments on the rising edge of the input capture signal. When the count value reaches the reload value a reload interrupt occurs and the interrupt function flips the LED.

16.9.2. Board Setting

Please refer to Pin Description for specific board. Connect external PWM signal to GPTMR capture pin.

16.9.3. Note

The example uses a default reload value of 0xFFFF. For better observation of LED blinking, it suggests using an external PWM frequency above 50KHz.

16.9.4. Running the example

When running the example, it performs the external counting mode of GPTMR, displaying the following message on the serial terminal and causing the onboard LED to blink

gptmr cnt_mode test
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger
reload trigger