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/16F150xPIC12/16F157xPIC12/16F161x
PIC12/16F184xPIC12/16LF155xPIC16F145x
PIC16F151xPIC16F152xPIC16F170x
PIC16F171xPIC16F176xPIC16F177x
PIC16F178xPIC16F194xPIC16LF156x
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.

Version: TMR0 Driver Version 2.0.0
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.

Parameters:
None.
Returns:

None.

Timer0_OverflowCallbackRegister()

void Timer0_OverflowCallbackRegister (void(*)(void) CallbackHandler)

Setter function for the Timer0 overflow callback.

Parameters:
CallbackHandler

- Pointer to custom callback

Returns:

None.

Timer0_OverflowISR()

void Timer0_OverflowISR (void )

Interrupt Service Routine (ISR) for the Timer0 overflow interrupt.

Parameters:
None.
Returns:

None.

Timer0_PeriodCountSet()

void Timer0_PeriodCountSet (size_t periodVal)

Loads the 8-bit value to the timer0ReloadVal variable.

Parameters:
periodVal

- 8-bit value

Returns:

None.

Timer0_Read()

uint8_t Timer0_Read (void )

Reads the 8-bit value from the Timer0 register.

Precondition:

Initialize Timer0 with Timer0_Initialize() before calling this API.

Parameters:
None.
Returns:

8-bit data from the Timer0 register

Timer0_Reload()

void Timer0_Reload (void )

Loads an 8-bit value to the Timer0 register.

Precondition:

Initialize Timer0 with Timer0_Initialize() before calling this API.

Parameters:
None.
Returns:

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.

Parameters:
timerVal

- 8-bit value to be written to the Timer0 register

Returns:

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/

tmr0.h

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

Detailed Description

This is the generated driver implementation file for the TMR0 driver.

TMR0 Generated Driver File

Version: TMR0 Driver Version 2.0.0

Function Documentation

Timer0_DefaultOverflowCallback()

static void Timer0_DefaultOverflowCallback (void )[static]

Variable Documentation

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.

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