16 Application Timer Service

Introduction

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/utlize 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.
  1. Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.
  2. Ensure that wireless_system_pic32cxbz_wbz 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 when prompted.
  5. Click on the Device Support dependecny satisfiers to know the device supported for this service and select pic32cx_bz3_devsupport.
  6. Click on the APP_TIMER_SERVICE to know the capability consumers and link the required component which is in need of the application timer service.
  7. Accept dependencies or satisfiers when prompted.
  8. Select the APP TIMER SERVICE component and provide the required configuration for Timer IDs.
  9. Here for e.g., BLE sensor application in the project as shown in below figure.
  10. For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
  11. 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 funcationlity 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 respectivly.
    Note: Refer the API details of APP TIMER for further details.