3.14.3 8-bit Timer/Counter2 with Async PWM

8-bit Timer/Counter2 with PWM and Asynchronous Operation

3.14.3.1 Introduction

The Timer/Counter2 is a general purpose, single channel, 8-bit Timer/Counter module. The Timer/Counter can be clocked internally, via the prescaler, or asynchronously clocked from the TOSC1/2 pins, as detailed later in this section. The asynchronous operation is controlled by the asynchronous status register (ASSR). The clock select logic block controls which clock source he Timer/Counter uses to increment (or decrement) its value. The Timer/Counter is inactive when no clock source is selected. The output from the clock select logic is referred to as the timer clock (clkT2).

3.14.3.2 Supported Device Families

ATmegaxxx

3.14.3.3 Required Header Files

#include "mcc_generated_files/tc2/tc2.h"

3.14.3.4 Module Documentation

3.14.3.4.1 TC2

This file contains the API prototypes and other data types for the Timer Counter 2 (TC2) driver.

Module description

This file contains the API prototypes and other data types for the Timer Counter 2 (TC2) driver.

Version: TC2 Driver Version 1.0.0
Functions

Function Documentation

TC2_Disable_COM2A_Interrupt()

void TC2_Disable_COM2A_Interrupt (void )

Disables the Compare A interrupt of the TC2 module.

Parameters:
None
Returns:

None.

TC2_Disable_COM2B_Interrupt()

void TC2_Disable_COM2B_Interrupt (void )

Disables the Compare B interrupt of the TC2 module.

Parameters:
None
Returns:

None.

TC2_Disable_Overflow_Interrupt()

void TC2_Disable_Overflow_Interrupt (void )

Disables the overflow interrupt of the TC2 module.

Parameters:
None.
Returns:

None.

TC2_Enable_COM2A_Interrupt()

void TC2_Enable_COM2A_Interrupt (void )

Enables the Compare A interrupt of the TC2 module.

Parameters:
None.
Returns:

None.

TC2_Enable_COM2B_Interrupt()

void TC2_Enable_COM2B_Interrupt (void )

Enables the Compare B interrupt of the TC2 module.

Parameters:
None
Returns:

None.

TC2_Enable_Overflow_Interrupt()

void TC2_Enable_Overflow_Interrupt (void )

Enables the overflow interrupt of the TC2 module.

Parameters:
None.
Returns:

None.

TC2_Get_COM2A_InterruptFlagStatus()

bool TC2_Get_COM2A_InterruptFlagStatus (void )

Checks the Compare A interrupt flag status of the TC2 module.

Parameters:
None
Return values:
True

- The counter value matches the Output Compare Register A.

False

- The counter value does not match the Output Compare Register A.

TC2_Get_COM2B_InterruptFlagStatus()

bool TC2_Get_COM2B_InterruptFlagStatus (void )

Checks the Compare B interrupt flag status of the TC2 module.

Parameters:
None
Return values:
True

- The counter value matches the Output Compare Register B.

False

- The counter value does not match the Output Compare Register B.

TC2_Get_Overflow_InterruptFlagStatus()

bool TC2_Get_Overflow_InterruptFlagStatus (void )

Checks the overflow Interrupt flag status of the TC2 module.

Parameters:
None
Return values:
True

- Timer Overflow is detected.

False

- Timer Overflow is not detected.

TC2_Initialize()

int8_t TC2_Initialize (void )

Initializes the TC2 module.

Parameters:
None
Return values:
0

- The TC2 initialization is successful.

1

- The TC2 initialization is unsuccessful.

TC2_ReadTimer()

uint8_t TC2_ReadTimer (void )

Reads the timer value of the TC2 module.

Parameters:
None
Return values:
uint8_t

- Timer register value.

TC2_WriteTimer()

void TC2_WriteTimer (uint8_t timerValue)

Writes a value to the TC2 timer register.

Parameters:
timerValue

- Value to be written to the timer register.

Returns:

None.

3.14.3.5 File Documentation

3.14.3.5.1 source/tc2.c File Reference

This file contains the API implementation for the Timer Counter 2 (TC2) module driver.

#include <avr/io.h>
#include "../tc2.h"

Functions

Detailed Description

This file contains the API implementation for the Timer Counter 2 (TC2) module driver.

TC2 Generated Driver File

Version: TC2 Driver Version 1.0.0

Function Documentation

ISR()[1/2]

ISR (TIMER2_COMPA_vect )

ISR()[2/2]

ISR (TIMER2_COMPB_vect )

3.14.3.5.2 source/tc2.h File Reference

#include "../system/utils/compiler.h"
#include <stdint.h>
#include <stdbool.h>

Functions

Detailed Description

TC2 Generated Driver API Header File