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.
- Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.
- Ensure that
wireless_system_pic32cxbz6_wbz65
repo is available locally in the development repo. - Open MCC. The Wireless System
Service components will be displayed in available components --> Wireless
--> System Services as shown in the below figure.
- Drag APP TIMER SERVICE component from available components to project graph area as shown in below figure. Accept Dependencies or satisfiers, select “Yes”.
- Select the APP TIMER SERVICE component and provide the required
configuration for Timer IDs.
- Here for example, BLE sensor
application in the project as shown in below figure.
- Generate the code - For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
- 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
- Users can use the
APP_TIMER_SetTimer
API function to start the timer functionality for the provided Timer ID. - 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.
- In
app.c
file function APP_Tasks, the posted task can be processed and executed for required functionalities within theAPP_STATE_SERVICE_TASKS
application state. - Function
APP_TIMER_StopTimer
andAPP_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.