10 Application Timer Service

The application timer service can be used to provide timer service required for the application functionality. Application timer service provides one shot or periodic timeout events for application.

Application Timer Service usage with MPLAB Code Configurator(MCC)

This section explains the steps required by a user to develop/utilize this application timer service using MPLABx MCC Framework

Note: It is recommended for the new users of the MPLAB Code Configurator to refer MPLAB® Code Configurator (MCC) User’s Guide in Reference Documentation from Related Links. Users can add/remove different components like peripheral support and other wireless functionality by following steps mentioned in MPLAB® Code Configurator (MCC) Classic, refer MPLAB® Code Configurator (MCC) Classic in Reference Documentation from Related Links.
  1. Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.
  2. Ensure that wireless_system_pic32cxbz6_wbz65 repo is available locally in the development repo.
  3. Open MCC. The Wireless System Service components will be displayed in available components --> Wireless --> System Services as shown in the below figure.
  4. Drag APP TIMER SERVICE component from available components to project graph area as shown in below figure. Accept Dependencies or satisfiers, select “Yes”.
  5. Select the APP TIMER SERVICE component and provide the required configuration for Timer IDs.
  6. Here for example, BLE sensor application in the project as shown in below figure.
  7. Generate the code - For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
  8. After generating the program source from MCC interface by clicking Generate Code, the application timer service can be found in the following project directories.

User Application Development

  1. Users can use the APP_TIMER_SetTimer API function to start the timer functionality for the provided Timer ID.
  2. The one shot timers will provide the required callback and post the message in the application task with the Timer message ID associated with the Timer ID provided.
  3. In app.c file function APP_Tasks, the posted task can be processed and executed for required functionalities within the APP_STATE_SERVICE_TASKS application state.
  4. Function APP_TIMER_StopTimer and APP_TIMER_ResetTimer can be used to stop the required timer ID and reset the required timer ID respectively.
    Note: Refer the API details of APP TIMER for further details.