Many engineers want to understand how something works before they commit to using it. Learning how to use the MPLAB® Harmony Framework is a much easier task than understanding how the underlying framework works. This page is for those engineers that feel the need for a deeper understanding of how the framework works.
The following information is provided to satisfy your curiosity. You do not need to understand this to use the MPLAB Harmony Framework.
This call graph shows the important functions in implementing the MPLAB Harmony Timer System Service Library. Refer the following table for a description of each function:
If you enable interrupts for the Timer Driver used by the Timer System Service, DRV_TMR_Tasks() will be called by the Interrupt Service Routin e(ISR) Timer, instead of being called by the SYS_Tasks().
Function Name | Source File | Description |
---|---|---|
SYS_TMR_Initialize | system_init.c | Specify Timer Driver index and System Tick frequency (Driver instance specified by the Timer Driver instance to use in MPLAB Harmony Configurator (MHC) (e.g. DRV_TMR_INDEX_0) ) (System Tick frequency specified by the Timer Running frequency in MHC) |
DRV_TMR_Open | drv_tmr.c | Create a client for a Timer Driver |
_SYS_TMR_Setup | sys_tmr.c | Calculate the timer period register value (Based on the Timer Running frequency value in MHC) Calculate the number of units to decrement the System Timer client counters for each System Timer tick (Decrement rate based on the value of Internal Time units in MHC) Initialize the System Timer object (sSysTmrObject) |
DRV_TMR_AlarmRegister | drv_tmr.c | Initialize Timer Driver client object returned from DRV_TMR_Open * Callback function for System Timer (not System Timer client) (Function name: _SYS_TMR_AlarmCallback) * Periodic or one-shot * Period (ms) = Timer Counter frequency / System Tick frequency * Alarm count = 0 |
_SYS_TMR_ProcessTmrAlarm | sys_tmr.c | Executed if System Timer tick occurred * Gets the number of system ticks (usually, just one) * Decrements each System Timer client counter by the number of system ticks * Client decrement rate (Client decrement rate name: sSysTmrObject.sysTickUnitCount) * If the client counter is <= 0, execute System Timer client callback function (Callback function name defined by you in SYS_TMR_CallbackPeriodic) |
DRV_TMR_ProcessEvents | drv_tmr.c | If the timer event flag is set (Timer counter = Timer Period register): * Clear flag * Increment the Timer Driver client alarm count * Execute the System Timer callback function (not System Timer client callback) Pass new alarm count to callback function (System Timer callback function name: _SYS_TMR_AlarmCallback) |
_SYS_TMR_AlarmCallback | sys_tmr.c | Assign new alarm count to the System Timer tick counter (System Timer tick count name: sSysTmrObject.sysTickCount) Execute the System Timer Process Timer Alarm function: * If using a System Timer interrupt, run the System Timer process alarm ISR ISR name: _SYS_TMR_ProcessIsrClients * If not using a System Timer interrupt, set System Timer object alarm received flag. Setting this flag causes _SYS_TMR_ProcessTmrAlarm to be executed. (Alarm received flag name: sSysTmrObject.alarmReceived) |
If Timer Driver Interrupts are enabled…
If you enable interrupts for the Timer Driver used by the Timer System Service, DRV_TMR_Tasks() will be called by the ISR Timer instead of the SYS_Tasks(). The ISR Timer can be found in the C source file SYSTEM_INTERRUPT.
file: SYSTEM_INTERRUPT
// Timer1 ISR (Timer Driver instance 0)
void __ISR(_TIMER_1_VECTOR, ipl1AUTO) IntHandlerDrvTmrInstance0(void)
{
DRV_TMR_Tasks (sysObj.drvTmr0); // pass pointer to object defining timer driver instance 0
}