3.24.1.1 8-bit TMR0
8-bit Timer0
3.24.1.1.1 Introduction
The Timer0 (TMR0) module is a versatile 8-bit timer/counter. It offers features like a customizable clock source, independent prescaler, and overflow interrupt. You can easily switch it between an 8-bit timer or counter to suit your needs.
3.24.1.1.2 Supported Device Families
PIC12/16F150x | PIC12/16F157x | PIC12/16F161x |
PIC12/16F184x | PIC12/16LF155x | PIC16F145x |
PIC16F151x | PIC16F152x | PIC16F170x |
PIC16F171x | PIC16F176x | PIC16F177x |
PIC16F178x | PIC16F194x | PIC16LF156x |
PIC16LF190x |
3.24.1.1.3 Required header files:
#include "mcc_generated_files/timer/tmr0.h"
3.24.1.1.4 Module Documentation
TMR0
This file contains API prototypes and other data types for the Timer0 (TMR0) driver.
Module description
This file contains API prototypes and other data types for the Timer0 (TMR0) driver.
Data structures
struct TMR_INTERFACE
This is an instance of TMR_INTERFACE for the Timer0 module.
Functions
void Timer0_Initialize (void)
Initializes the Timer0 module. This routine is called once, before any other Timer0 routine.
uint8_t Timer0_Read (void)
Reads the 8-bit value from the Timer0 register.
void Timer0_Write (size_t timerVal)
Writes an 8-bit value to the Timer0 register. Initialize Timer0 with Timer0_Initialize() before calling this API.
void Timer0_Reload (void)
Loads an 8-bit value to the Timer0 register.
void Timer0_PeriodCountSet (size_t periodVal)
Loads the 8-bit value to the timer0ReloadVal variable.
void Timer0_OverflowISR (void)
Interrupt Service Routine (ISR) for the Timer0 overflow interrupt.
void Timer0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Setter function for the Timer0 overflow callback.
Function Documentation
Timer0_Initialize()
void Timer0_Initialize (void )
Initializes the Timer0 module. This routine is called once, before any other Timer0 routine.
None. |
None. |
Timer0_OverflowCallbackRegister()
void Timer0_OverflowCallbackRegister (void(*)(void) CallbackHandler)
Setter function for the Timer0 overflow callback.
CallbackHandler |
- Pointer to custom callback |
None. |
Timer0_OverflowISR()
void Timer0_OverflowISR (void )
Interrupt Service Routine (ISR) for the Timer0 overflow interrupt.
None. |
None. |
Timer0_PeriodCountSet()
void Timer0_PeriodCountSet (size_t periodVal)
Loads the 8-bit value to the timer0ReloadVal variable.
periodVal |
- 8-bit value |
None. |
Timer0_Read()
uint8_t Timer0_Read (void )
Reads the 8-bit value from the Timer0 register.
Initialize Timer0 with Timer0_Initialize() before calling this API. |
None. |
8-bit data from the Timer0 register |
Timer0_Reload()
void Timer0_Reload (void )
Loads an 8-bit value to the Timer0 register.
Initialize Timer0 with Timer0_Initialize() before calling this API. |
None. |
None. |
Timer0_Write()
void Timer0_Write (size_t timerVal)
Writes an 8-bit value to the Timer0 register. Initialize Timer0 with Timer0_Initialize() before calling this API.
timerVal |
- 8-bit value to be written to the Timer0 register |
None. |
3.24.1.1.5 Class Documentation
TMR_INTERFACE Struct Reference
This is an instance of TMR_INTERFACE for the Timer0 module.
Detailed Description
This is an instance of TMR_INTERFACE for the Timer0 module.
#include <tmr0.h>
The documentation for this struct was generated from the following file:
source/
3.24.1.1.6 File Documentation
source/tmr0.c File Reference
This is the generated driver implementation file for the TMR0 driver.
#include <xc.h> #include "../tmr0.h"
Functions
static void Timer0_DefaultOverflowCallback (void)
void Timer0_Initialize (void)
Initializes the Timer0 module. This routine is called once, before any other Timer0 routine.
uint8_t Timer0_Read (void)
Reads the 8-bit value from the Timer0 register.
void Timer0_Write (size_t timerVal)
Writes an 8-bit value to the Timer0 register. Initialize Timer0 with Timer0_Initialize() before calling this API.
void Timer0_Reload (void)
Loads an 8-bit value to the Timer0 register.
void Timer0_PeriodCountSet (size_t periodVal)
Loads the 8-bit value to the timer0ReloadVal variable.
void Timer0_OverflowISR (void)
Interrupt Service Routine (ISR) for the Timer0 overflow interrupt.
void Timer0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Setter function for the Timer0 overflow callback.
Variables
volatile uint8_t timer0ReloadVal
const struct TMR_INTERFACE Timer0
static void(* Timer0_OverflowCallback )(void)
Detailed Description
This is the generated driver implementation file for the TMR0 driver.
TMR0 Generated Driver File
Function Documentation
Timer0_DefaultOverflowCallback()
static void Timer0_DefaultOverflowCallback (void )[static]
Variable Documentation
Timer0
const struct TMR_INTERFACE Timer0
Initial value:
= { .Initialize = Timer0_Initialize, .Start = NULL, .Stop = NULL, .PeriodCountSet = Timer0_PeriodCountSet, .TimeoutCallbackRegister = Timer0_OverflowCallbackRegister, .Tasks = NULL }
Timer0_OverflowCallback
void(* Timer0_OverflowCallback) (void)[static]
timer0ReloadVal
volatile uint8_t timer0ReloadVal
source/tmr0.h File Reference
#include "timer_interface.h" #include <stdbool.h> #include <stdint.h>
Functions
void Timer0_Initialize (void)
Initializes the Timer0 module. This routine is called once, before any other Timer0 routine.
uint8_t Timer0_Read (void)
Reads the 8-bit value from the Timer0 register.
void Timer0_Write (size_t timerVal)
Writes an 8-bit value to the Timer0 register. Initialize Timer0 with Timer0_Initialize() before calling this API.
void Timer0_Reload (void)
Loads an 8-bit value to the Timer0 register.
void Timer0_PeriodCountSet (size_t periodVal)
Loads the 8-bit value to the timer0ReloadVal variable.
void Timer0_OverflowISR (void)
Interrupt Service Routine (ISR) for the Timer0 overflow interrupt.
void Timer0_OverflowCallbackRegister (void(*CallbackHandler)(void))
Setter function for the Timer0 overflow callback.
Macros
#define Timer0_INTERRUPT_TICKER_FACTOR 2
Variables
const struct TMR_INTERFACE Timer0
Detailed Description
TMR0 Generated Driver API Header File
Macro Definition Documentation
Timer0_INTERRUPT_TICKER_FACTOR
#define Timer0_INTERRUPT_TICKER_FACTOR 2
Variable Documentation
Timer0
const struct TMR_INTERFACE Timer0