3.24.1.2 8/16-bit TMR0
8/16-bit Timer0
3.24.1.2.1 Introduction
The Timer0 (TMR0) module is a flexible 8/16-bit timer with configurable time-out period.
3.24.1.2.2 Supported Device Families
PIC12/16F184x | PIC16F152xx | PIC16F153xx |
PIC16F171x | PIC16F171xx | PIC16F180xx |
PIC16F181xx | PIC16F183xx | PIC16F184xx |
PIC16F188xx | PIC16F191xx | PIC18F-K20 |
PIC18F-K22 | PIC18F-K40 | PIC18F-K42 |
PIC18F-K50 | PIC18F-K80 | PIC18F-K83 |
PIC18F-K90 | PIC18F-Q10 | PIC18F-Q20 |
PIC18F-Q40 | PIC18F-Q41 | PIC18F-Q43 |
PIC18F-Q71 | PIC18F-Q83 | PIC18F-Q84 |
3.24.1.2.3 Required header files:
#include "mcc_generated_files/timer/tmr0.h"
3.24.1.2.4 How to use the Timer 0 PLIB
Click the links to view the code snippets associated with each example:
- Timer0 Use Case 1: Timer Period Change in 16-bit Mode This example demonstrates an application where the timer period changes from 4 ms to 8 ms and vice versa with every overflow of the timer.
- Timer0 Use Case 2: LED Toggle in 8-bit Mode This example toggles an LED when an period match interrupt event occurs.
- Timer0 Use Case 3: Timer Wake from Sleep at Interrupt event This example wakes the microcontroller from Sleep mode every five seconds.
3.24.1.2.5 Specific MISRA C:2012 Deviations
- Global TMR0_MAX_COUNT
-
Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not. - Global TMR0_Read
-
Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.
3.24.1.2.6 Module Documentation
TMR0 in 16-Bit Mode
This file contains API prototypes and other data types for the TMR0 driver.
Module description
This file contains API prototypes and other data types for the TMR0 driver.
This file contains the deprecated macros or APIs for the TMR0 driver.
Definitions
#define TMR0_MAX_COUNT (65535U)
Defines the maximum count value of the timer.
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
#define Timer0_Reload TMR0_Reload
Defines the Custom Name for the TMR0_Reload API. This macro will be deprecated in the future release.
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
#define Timer0_OverflowStatusGet TMR0_OverflowStatusGet
Defines the Custom Name for the TMR0_OverflowStatusGet API.
#define Timer0_OverflowStatusClear TMR0_OverflowStatusClear
Defines the Custom Name for the TMR0_OverflowStatusClear API.
#define Timer0_OverflowCallbackRegister TMR0_OverflowCallbackRegister
Defines the Custom Name for the TMR0_OverflowCallbackRegister API.
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
Functions
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint16_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint16_t counterValue)
Sets the counter value.
void TMR0_Reload (void)
Reloads the period value.
void TMR0_PeriodSet (uint16_t periodCount)
Sets the period count value.
uint16_t TMR0_PeriodGet (void)
Returns the current period value.
uint16_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_OverflowStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_OverflowStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
void TMR0_TMRInterruptEnable (void)
Enables the TMR0 interrupt.
void TMR0_TMRInterruptDisable (void)
Disables the TMR0 interrupt.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
Definition Documentation
TIMER0_CLOCK_FREQ
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
Timer0_CounterGet
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
Timer0_CounterSet
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
Timer0_Deinitialize
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
Timer0_Initialize
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
Timer0_ISR
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
TIMER0_MAX_COUNT
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
Timer0_MaxCountGet
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
Timer0_OverflowCallbackRegister
#define Timer0_OverflowCallbackRegister TMR0_OverflowCallbackRegister
Defines the Custom Name for the TMR0_OverflowCallbackRegister API.
Timer0_OverflowStatusClear
#define Timer0_OverflowStatusClear TMR0_OverflowStatusClear
Defines the Custom Name for the TMR0_OverflowStatusClear API.
Timer0_OverflowStatusGet
#define Timer0_OverflowStatusGet TMR0_OverflowStatusGet
Defines the Custom Name for the TMR0_OverflowStatusGet API.
Timer0_PeriodCountSet
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
Timer0_PeriodGet
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
Timer0_PeriodSet
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
Timer0_Read
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
Timer0_Reload
#define Timer0_Reload TMR0_Reload
Defines the Custom Name for the TMR0_Reload API. This macro will be deprecated in the future release.
Timer0_Start
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
Timer0_Stop
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
Timer0_Tasks
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
Timer0_TMRInterruptDisable
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
Timer0_TMRInterruptEnable
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
Timer0_Write
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
TMR0_CLOCK_FREQ
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
TMR0_INTERRUPT_TICKER_FACTOR
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
TMR0_MAX_COUNT
#define TMR0_MAX_COUNT (65535U)
Defines the maximum count value of the timer.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TMR0_PeriodCountSet
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
TMR0_Read
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TMR0_Write
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
Function Documentation
TMR0_CounterGet()
uint16_t TMR0_CounterGet (void )
Returns the current counter value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Counter value from the TMR0 register |
TMR0_CounterSet()
void TMR0_CounterSet (uint16_t counterValue)
Sets the counter value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
counterValue |
- Counter value to be written to the TMR0 register |
None. |
TMR0_Deinitialize()
void TMR0_Deinitialize (void )
Deinitializes the TMR0 module.
None. |
None. |
TMR0_Initialize()
void TMR0_Initialize (void )
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
None. |
None. |
Section: TMR0 APIs
TMR0_ISR()
void TMR0_ISR (void )
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
None. |
None. |
TMR0_MaxCountGet()
uint16_t TMR0_MaxCountGet (void )
Returns the maximum count value.
None. |
Maximum count value |
TMR0_OverflowCallbackRegister()
void TMR0_OverflowCallbackRegister (void(*)(void) CallbackHandler)
Registers a callback function for the TMR0 overflow or period match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TMR0_OverflowStatusClear()
void TMR0_OverflowStatusClear (void )
Clears the TMR0 Interrupt flag.
None. |
None. |
TMR0_OverflowStatusGet()
bool TMR0_OverflowStatusGet (void )
Returns the status of the TMR0 Interrupt flag.
None. |
Interrupt flag status |
TMR0_PeriodGet()
uint16_t TMR0_PeriodGet (void )
Returns the current period value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Period count value |
TMR0_PeriodSet()
void TMR0_PeriodSet (uint16_t periodCount)
Sets the period count value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
PeriodCount |
- Period count value to be written to the TMR0 register |
None. |
TMR0_Reload()
void TMR0_Reload (void )
Reloads the period value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
None. |
TMR0_Start()
void TMR0_Start (void )
Starts the TMR0 timer.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
None. |
TMR0_Stop()
void TMR0_Stop (void )
Stops the TMR0 timer.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
None. |
TMR0_Tasks()
void TMR0_Tasks (void )
Performs tasks to be executed during the timer interrupt event.
None. |
None. |
TMR0_TMRInterruptDisable()
void TMR0_TMRInterruptDisable (void )
Disables the TMR0 interrupt.
None. |
None. |
TMR0_TMRInterruptEnable()
void TMR0_TMRInterruptEnable (void )
Enables the TMR0 interrupt.
None. |
None. |
TMR0 in 8-Bit Mode
This file contains API prototypes and other data types for the TMR0 driver.
Module description
This file contains API prototypes and other data types for the TMR0 driver.
This file contains the deprecated macros or APIs for the TMR0 driver.
Definitions
#define TMR0_MAX_COUNT (255U)
Defines the maximum count value of the timer.
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
#define Timer0_PeriodMatchStatusGet TMR0_PeriodMatchStatusGet
Defines the Custom Name for the TMR0_PeriodMatchStatusGet API.
#define Timer0_PeriodMatchStatusClear TMR0_PeriodMatchStatusClear
Defines the Custom Name for the TMR0_PeriodMatchStatusClear API.
#define Timer0_PeriodMatchCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API.
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define TMR0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define TMR0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The TMR0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
#define Timer0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The Timer0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
Functions
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint8_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint8_t counterValue)
Sets the counter value.
void TMR0_PeriodSet (uint8_t periodCount)
Sets the period value.
uint8_t TMR0_PeriodGet (void)
Returns the current period value.
uint8_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_PeriodMatchStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_PeriodMatchStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_PeriodMatchCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
void TMR0_TMRInterruptEnable (void)
Enables the TMR0 interrupt.
void TMR0_TMRInterruptDisable (void)
Disables the TMR0 interrupt.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
Definition Documentation
TIMER0_CLOCK_FREQ
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
Timer0_CounterGet
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
Timer0_CounterSet
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
Timer0_Deinitialize
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
Timer0_Initialize
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
Timer0_ISR
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
TIMER0_MAX_COUNT
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
Timer0_MaxCountGet
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
Timer0_OverflowCallbackRegister
#define Timer0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The Timer0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
Timer0_PeriodCountSet
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
Timer0_PeriodGet
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
Timer0_PeriodMatchCallbackRegister
#define Timer0_PeriodMatchCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API.
Timer0_PeriodMatchStatusClear
#define Timer0_PeriodMatchStatusClear TMR0_PeriodMatchStatusClear
Defines the Custom Name for the TMR0_PeriodMatchStatusClear API.
Timer0_PeriodMatchStatusGet
#define Timer0_PeriodMatchStatusGet TMR0_PeriodMatchStatusGet
Defines the Custom Name for the TMR0_PeriodMatchStatusGet API.
Timer0_PeriodSet
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
Timer0_Read
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
Timer0_Reload
#define Timer0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
Timer0_Start
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
Timer0_Stop
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
Timer0_Tasks
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
Timer0_TMRInterruptDisable
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
Timer0_TMRInterruptEnable
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
Timer0_Write
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
TMR0_CLOCK_FREQ
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
TMR0_INTERRUPT_TICKER_FACTOR
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
TMR0_MAX_COUNT
#define TMR0_MAX_COUNT (255U)
Defines the maximum count value of the timer.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TMR0_OverflowCallbackRegister
#define TMR0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The TMR0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
TMR0_PeriodCountSet
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
TMR0_Read
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
MISRA C:2012 Deviation Advisory: misra-c2012-2.5
Justification: MCC Melody drivers provide macros that can be added to an application. It depends on the application whether a macro is used or not.TMR0_Reload
#define TMR0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
TMR0_Write
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
Function Documentation
TMR0_CounterGet()
uint8_t TMR0_CounterGet (void )
Returns the current counter value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Counter value from the TMR0L register |
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Counter value from the TMR0 register |
TMR0_CounterSet()
void TMR0_CounterSet (uint8_t counterValue)
Sets the counter value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
counterValue |
- Counter value to be written to the TMR0L register |
None. |
TMR0_Deinitialize()
void TMR0_Deinitialize (void )
Deinitializes the TMR0 module.
None. |
None. |
TMR0_Initialize()
void TMR0_Initialize (void )
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
None. |
None. |
Section: TMR0 APIs
TMR0_ISR()
void TMR0_ISR (void )
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
None. |
None. |
TMR0_MaxCountGet()
uint8_t TMR0_MaxCountGet (void )
Returns the maximum count value.
None. |
Maximum count value |
TMR0_PeriodGet()
uint8_t TMR0_PeriodGet (void )
Returns the current period value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Period count value from the TMR0H register |
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
Period count value |
TMR0_PeriodMatchCallbackRegister()
void TMR0_PeriodMatchCallbackRegister (void(*)(void) CallbackHandler)
Registers a callback function for the TMR0 overflow or period match event.
CallbackHandler |
- Address to the custom callback function |
None. |
TMR0_PeriodMatchStatusClear()
void TMR0_PeriodMatchStatusClear (void )
Clears the TMR0 Interrupt flag.
None. |
None. |
TMR0_PeriodMatchStatusGet()
bool TMR0_PeriodMatchStatusGet (void )
Returns the status of the TMR0 Interrupt flag.
None. |
Interrupt flag status |
TMR0_PeriodSet()
void TMR0_PeriodSet (uint8_t periodCount)
Sets the period value.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
periodCount |
- Period count value written to the TMR0H register |
None. |
TMR0_Start()
void TMR0_Start (void )
Starts the TMR0 timer.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
None. |
TMR0_Stop()
void TMR0_Stop (void )
Stops the TMR0 timer.
Initialize TMR0 with TMR0_Initialize() before calling this API. |
None. |
None. |
TMR0_Tasks()
void TMR0_Tasks (void )
Performs tasks to be executed during the timer interrupt event.
None. |
None. |
TMR0_TMRInterruptDisable()
void TMR0_TMRInterruptDisable (void )
Disables the TMR0 interrupt.
None. |
None. |
TMR0_TMRInterruptEnable()
void TMR0_TMRInterruptEnable (void )
Enables the TMR0 interrupt.
None. |
None. |
3.24.1.2.7 TMR0 Examples
This section explains various use case examples of the Timer module within an MPLAB® Code Configurator (MCC) Melody Project.
TMR0 PLIB Examples
4 ms/8 ms Timer Period Change in 16-bit Timer Non-Interrupt Mode
This use case configures the TMR0 PLIB in 16-bit mode to generate the timer period. The period of a timer is changed at run time during each overflow event. The callback function is used to change the timer period.
-
System>Clock Control:
-
Clock Source: HFINTOSC
-
HF Internal Clock: 64 MHz
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TMR0:
-
Timer Enable: False
-
Timer Mode: 16-bit
-
Prescaler: 1:64
-
TMR Interrupt Enable: False
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: PIC18F57Q43 Curiosity Nano Board * MCC Configuration: * Clock Control: HFINTOSC (64 MHz) * TMR0 module: Timer Enable - False, Timer Mode - 16-bit, Prescaler - 1:64, TMR Interrupt Enable - False * Pins module: RF3 - GPIO Output, CustomName - LED */ #define USE_TASKS_API 1 #define MS_TO_TICKS(ms) (((TMR0_CLOCK_FREQ * (ms)) / 1000UL) - 1UL) #define LED_4_MS (TMR0_MAX_COUNT - MS_TO_TICKS(4UL)) #define LED_8_MS (TMR0_MAX_COUNT - MS_TO_TICKS(8UL)) static void Timer_PeriodChange(void) { static volatile bool changePeriod = false; LED_Toggle(); TMR0_Stop(); uint16_t maxCount = TMR0_MaxCountGet(); uint16_t newPeriod = changePeriod ? LED_4_MS:LED_8_MS; if(maxCount > newPeriod) { TMR0_PeriodSet(newPeriod); TMR0_CounterSet(newPeriod); } else { // Invalid period } changePeriod = !changePeriod; TMR0_Start(); } int main(void) { SYSTEM_Initialize(); TMR0_PeriodSet(LED_4_MS); TMR0_CounterSet(LED_4_MS); TMR0_OverflowStatusClear(); #if USE_TASKS_API TMR0_OverflowCallbackRegister(Timer_PeriodChange); #endif TMR0_Start(); while(1) { #if USE_TASKS_API TMR0_Tasks(); #else if(1U == TMR0_OverflowStatusGet()) { Timer_PeriodChange(); TMR0_OverflowStatusClear(); } #endif } }
4 ms Timer Period in 8-bit Timer Interrupt Mode
This use case configures the TMR0 PLIB in 8-bit mode to generate the period match interrupt at a period of 4 ms, while toggling an LED. This use case uses the generated APIs to set the timer period.
-
System>Clock Control:
-
Clock Source: HFINTOSC
-
HF Internal Clock: 64 MHz
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TMR0:
-
Timer Enable: False
-
Timer Mode: 8-bit
-
Prescaler: 1:128
-
Postscaler: 1:16
-
TMR Interrupt Enable: True
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: PIC18F57Q43 Curiosity Nano Board * MCC Configuration: * Clock Control: HFINTOSC (64 MHz) * TMR0 module: Timer Enable - False, Timer Mode - 8-bit, Prescaler - 1:128, Postscaler - 1:16, TMR Interrupt Enable - True * Pins module: RF3 - GPIO Output, CustomName - LED */ #define POSTSCALER 16UL #define MS_TO_TICKS(ms) (((TMR0_CLOCK_FREQ * (ms)) / 1000UL) - 1UL) #define LED_4_MS (MS_TO_TICKS(4UL)/POSTSCALER) void Custom_Callback(void) { LED_Toggle(); } int main(void) { SYSTEM_Initialize(); myTimer_CounterSet(0); if(myTimer_MaxCountGet() > LED_4_MS) { myTimer_PeriodSet(LED_4_MS); } else { //Invalid period //Generate default timer period } myTimer_PeriodMatchCallbackRegister(Custom_Callback); myTimer_Start(); INTERRUPT_GlobalInterruptEnable(); while(1) { } }
Timer Wake From Sleep at Every 5s
This use case configures the TMR0 PLIB in 8-bit mode to wake the microcontroller from Sleep mode every five seconds. The wake up event toggles an LED, then puts the MCU back to Sleep.
-
System>Clock Control:
-
Clock Source: HFINTOSC
-
HF Internal Clock: 64 MHz
-
-
System>Pins:
-
Pin Grid View: Select LED pin as output (Check the schematic for your board)
-
Pins: Rename Custom Name to "LED"
-
-
Drivers>TMR0:
-
Timer Enable: True
-
Timer Mode: 8-bit
-
Clock Source: LFINTOSC
-
Synchronization Enable: False
-
Prescaler: 1:64
-
Postscaler: 1:10
-
Requested Period: 5s
-
TMR Interrupt Enable: True
-
After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:
#include "mcc_generated_files/system/system.h" /* * Development Board: PIC18F57Q43 Curiosity Nano Board * MCC Configuration: * System module: HFINTOSC (64 MHz) * TMR0 module: Timer Enable - True, Timer Mode - 8-bit, Clock Source - LFINTOSC, Synchronization Enable - False, Prescaler - 1:64, Postscaler - 1:10, Requested Period - 5s, TMR Interrupt Enable - True * Pins module: RF3 - GPIO Output, CustomName - LED */ int main(void) { SYSTEM_Initialize(); // Enable the Global Interrupts INTERRUPT_GlobalInterruptEnable(); while(1) { LED_Toggle(); SLEEP(); // Add your code here to execute after exiting Sleep mode } }
3.24.1.2.8 File Documentation
source/tmr0_16bit.c File Reference
#include <xc.h> #include "../tmr0.h"
Functions
static void TMR0_DefaultCallback (void)
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint16_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint16_t counterValue)
Sets the counter value.
void TMR0_Reload (void)
Reloads the period value.
void TMR0_PeriodSet (uint16_t periodCount)
Sets the period count value.
uint16_t TMR0_PeriodGet (void)
Returns the current period value.
uint16_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_OverflowStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_OverflowStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_OverflowCallbackRegister (void(*callbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
Variables
static volatile uint16_t tmr0PeriodCount
static void(* TMR0_OverflowCallback )(void)
Function Documentation
TMR0_DefaultCallback()
static void TMR0_DefaultCallback (void )[static]
Variable Documentation
TMR0_OverflowCallback
void(* TMR0_OverflowCallback) (void)[static]
tmr0PeriodCount
volatile uint16_t tmr0PeriodCount[static]
source/tmr0_16bit.h File Reference
#include <stdint.h> #include <stdbool.h> #include "tmr0_deprecated.h"
Functions
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint16_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint16_t counterValue)
Sets the counter value.
void TMR0_Reload (void)
Reloads the period value.
void TMR0_PeriodSet (uint16_t periodCount)
Sets the period count value.
uint16_t TMR0_PeriodGet (void)
Returns the current period value.
uint16_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_OverflowStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_OverflowStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
void TMR0_TMRInterruptEnable (void)
Enables the TMR0 interrupt.
void TMR0_TMRInterruptDisable (void)
Disables the TMR0 interrupt.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
Macros
#define TMR0_MAX_COUNT (65535U)
Defines the maximum count value of the timer.
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
#define Timer0_Reload TMR0_Reload
Defines the Custom Name for the TMR0_Reload API. This macro will be deprecated in the future release.
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
#define Timer0_OverflowStatusGet TMR0_OverflowStatusGet
Defines the Custom Name for the TMR0_OverflowStatusGet API.
#define Timer0_OverflowStatusClear TMR0_OverflowStatusClear
Defines the Custom Name for the TMR0_OverflowStatusClear API.
#define Timer0_OverflowCallbackRegister TMR0_OverflowCallbackRegister
Defines the Custom Name for the TMR0_OverflowCallbackRegister API.
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
source/tmr0_8bit.c File Reference
#include <xc.h> #include "../tmr0.h"
Functions
static void TMR0_DefaultCallback (void)
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint8_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint8_t counterValue)
Sets the counter value.
void TMR0_PeriodSet (uint8_t periodValue)
Sets the period value.
uint8_t TMR0_PeriodGet (void)
Returns the current period value.
uint8_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_PeriodMatchStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_PeriodMatchStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_PeriodMatchCallbackRegister (void(*callbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
Variables
static void(* TMR0_PeriodMatchCallback )(void)
Function Documentation
TMR0_DefaultCallback()
static void TMR0_DefaultCallback (void )[static]
Variable Documentation
TMR0_PeriodMatchCallback
void(* TMR0_PeriodMatchCallback) (void)[static]
source/tmr0_8bit.h File Reference
#include <stdint.h> #include <stdbool.h> #include "tmr0_deprecated.h"
Functions
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint8_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint8_t counterValue)
Sets the counter value.
void TMR0_PeriodSet (uint8_t periodCount)
Sets the period value.
uint8_t TMR0_PeriodGet (void)
Returns the current period value.
uint8_t TMR0_MaxCountGet (void)
Returns the maximum count value.
bool TMR0_PeriodMatchStatusGet (void)
Returns the status of the TMR0 Interrupt flag.
void TMR0_PeriodMatchStatusClear (void)
Clears the TMR0 Interrupt flag.
void TMR0_Tasks (void)
Performs tasks to be executed during the timer interrupt event.
void TMR0_PeriodMatchCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
void TMR0_TMRInterruptEnable (void)
Enables the TMR0 interrupt.
void TMR0_TMRInterruptDisable (void)
Disables the TMR0 interrupt.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
Macros
#define TMR0_MAX_COUNT (255U)
Defines the maximum count value of the timer.
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TMR0_INTERRUPT_TICKER_FACTOR (5U)
Defines the timer interrupt ticker factor.
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
#define Timer0_PeriodMatchStatusGet TMR0_PeriodMatchStatusGet
Defines the Custom Name for the TMR0_PeriodMatchStatusGet API.
#define Timer0_PeriodMatchStatusClear TMR0_PeriodMatchStatusClear
Defines the Custom Name for the TMR0_PeriodMatchStatusClear API.
#define Timer0_PeriodMatchCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API.
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
#define Timer0_TMRInterruptEnable TMR0_TMRInterruptEnable
Defines the Custom Name for the TMR0_TMRInterruptEnable API.
#define Timer0_TMRInterruptDisable TMR0_TMRInterruptDisable
Defines the Custom Name for the TMR0_TMRInterruptDisable API.
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
source/tmr0_deprecated_16bit.h File Reference
#include <stdint.h> #include <stdbool.h>
Macros
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
source/tmr0_deprecated_8bit.h File Reference
#include <stdint.h> #include <stdbool.h>
Macros
#define TMR0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define Timer0_Read TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API. The Timer0_Read will be deprecated in the future release. Use TMR0_CounterGet instead.
#define TMR0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define Timer0_Write TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API. The Timer0_Write will be deprecated in the future release. Use TMR0_CounterSet instead.
#define TMR0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_PeriodCountSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define TMR0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The TMR0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define Timer0_Reload TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API. The Timer0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead.
#define TMR0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The TMR0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
#define Timer0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister
Defines the Custom Name for the TMR0_PeriodMatchCallbackRegister API. The Timer0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead.
source/tmr0_drv.c File Reference
#include <xc.h> #include "../tmr0.h"
Functions
static void TMR0_DefaultOverflowCallback (void)
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint32_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint32_t counterValue)
Sets the counter value.
void TMR0_PeriodSet (uint32_t periodCount)
Sets the period count value.
uint32_t TMR0_PeriodGet (void)
Returns the current period value.
uint32_t TMR0_MaxCountGet (void)
Returns the maximum count value.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt.
void TMR0_OverflowCallbackRegister (void(*callbackHandler)(void))
Registers a callback function for the TMR0 overflow or period match event.
Variables
const struct TIMER_INTERFACE Timer0
static volatile uint16_t tmr0PeriodCount
static void(* TMR0_OverflowCallback )(void)
Function Documentation
TMR0_DefaultOverflowCallback()
static void TMR0_DefaultOverflowCallback (void )[static]
Variable Documentation
Timer0
const struct TIMER_INTERFACE Timer0
Initial value:
= { .Initialize = TMR0_Initialize, .Deinitialize = TMR0_Deinitialize, .Start = TMR0_Start, .Stop = TMR0_Stop, .PeriodSet = TMR0_PeriodSet, .PeriodGet = TMR0_PeriodGet, .CounterGet = TMR0_CounterGet, .CounterSet = TMR0_CounterSet, .MaxCountGet = TMR0_MaxCountGet, .TimeoutCallbackRegister = TMR0_OverflowCallbackRegister, .Tasks = NULL }
TMR0_OverflowCallback
void(* TMR0_OverflowCallback) (void)[static]
tmr0PeriodCount
volatile uint16_t tmr0PeriodCount[static]
source/tmr0_drv.h File Reference
#include <stdint.h> #include <stdbool.h> #include "timer_interface.h"
Functions
void TMR0_Initialize (void)
Initializes the Timer0 (TMR0) module. This routine must be called before any other TMR0 routines.
void TMR0_Deinitialize (void)
Deinitializes the TMR0 module.
void TMR0_Start (void)
Starts the TMR0 timer.
void TMR0_Stop (void)
Stops the TMR0 timer.
uint32_t TMR0_CounterGet (void)
Returns the current counter value.
void TMR0_CounterSet (uint32_t counterValue)
Sets the counter value.
void TMR0_PeriodSet (uint32_t periodCount)
Sets the period count value.
uint32_t TMR0_PeriodGet (void)
Returns the current period value.
uint32_t TMR0_MaxCountGet (void)
Returns the maximum count value.
void TMR0_ISR (void)
Interrupt Service Routine (ISR) for the TMR0 overflow interrupt.
void TMR0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Registers a callback function for the TMR0 overflow event.
void TMR0_Tasks (void)
Performs tasks to be executed during the TMR0 overflow event.
Macros
#define TMR0_MAX_COUNT (65535U)
Defines the maximum count value of the timer.
#define TMR0_CLOCK_FREQ (32000000UL)
Defines the timer prescaled clock frequency in hertz.
#define TIMER0_MAX_COUNT TMR0_MAX_COUNT
Defines the Custom Name for the TMR0_MAX_COUNT.
#define TIMER0_CLOCK_FREQ TMR0_CLOCK_FREQ
Defines the Custom Name for the TMR0_CLOCK_FREQ.
#define Timer0_Initialize TMR0_Initialize
Defines the Custom Name for the TMR0_Initialize API.
#define Timer0_Deinitialize TMR0_Deinitialize
Defines the Custom Name for the TMR0_Deinitialize API.
#define Timer0_Start TMR0_Start
Defines the Custom Name for the TMR0_Start API.
#define Timer0_Stop TMR0_Stop
Defines the Custom Name for the TMR0_Stop API.
#define Timer0_CounterGet TMR0_CounterGet
Defines the Custom Name for the TMR0_CounterGet API.
#define Timer0_CounterSet TMR0_CounterSet
Defines the Custom Name for the TMR0_CounterSet API.
#define Timer0_PeriodSet TMR0_PeriodSet
Defines the Custom Name for the TMR0_PeriodSet API.
#define Timer0_PeriodGet TMR0_PeriodGet
Defines the Custom Name for the TMR0_PeriodGet API.
#define Timer0_MaxCountGet TMR0_MaxCountGet
Defines the Custom Name for the TMR0_MaxCountGet API.
#define Timer0_ISR TMR0_ISR
Defines the Custom Name for the TMR0_ISR API.
#define Timer0_Tasks TMR0_Tasks
Defines the Custom Name for the TMR0_Tasks API.
#define Timer0_OverflowCallbackRegister TMR0_OverflowCallbackRegister
Defines the Custom Name for the TMR0_OverflowCallbackRegister API.
Variables
const struct TIMER_INTERFACE Timer0
Variable Documentation
Timer0
const struct TIMER_INTERFACE Timer0