TIMER Reload Mode

This sample code guide is designed to help users easily and comprehensively understand TIMER sample. This sample demonstrates how TIMER module works in reload mode and it will trigger the interrupt every 3 seconds.

Requirements

For hardware requirements, please refer to the Requirements.

Configurations

  1. The entry function is as follows, call this function in main() to run this sample code. For more details, please refer to the Initialization.

    tim_demo();
    

Building and Downloading

For building and downloading, please refer to the Building and Downloading.

Experimental Verification

Press the Reset button on the EVB, print the following log in Debug Analyzer every 3 seconds.

demo_hw_timer_callback

Code Overview

This section introduces the code and process description for initialization and corresponding function implementation in the sample.

Source Code Directory

  • For project directory, please refer to Source Code Directory.

  • Source code directory: sdk\src\sample\io_demo\tim\interrupt\tim_demo.c.

Initialization

The initialization flow for peripherals can refer to Initialization Flow.

  1. Call hw_timer_create() to create a TIMER with a period value of 3 seconds and reload mode.

  2. Call hw_timer_start() to start the TIMER.

Functional Implementation

Callback Handle

After start the TIMER, the TIMER begins timing. When the timing period ends, the interrupt will be triggered and the callback will be executed:

  1. Print the following log.

    demo_hw_timer_callback