3.14.8 24-bit Timer/Counter F with PWM

24-bit Timer/Counter type F (TCF) offering three Counter Operation Modes.

3.14.8.1 Introduction

The 24-bit Timer/Counter type F (TCF) offers three Counter Operation Modes up to 24-bit, with a 7 bit Prescaler and Overflow and compare match: Frequency generation, Numerical Controller Oscillator and 8-bit Pulse-Width Modulation. It has Event generation as pulse or waveform output and it allows clocking from multiple sources.

3.14.8.2 Supported Device Families

AVR® EB

3.14.8.3 Required header files:


#include "mcc_generated_files/timer/tcf[X].h"
Note: Replace [X] with the selected instance number of the TCF module.

3.14.8.4 Module Documentation

3.14.8.4.1 TCF0

This document contains the implementation of the public and private functions for the Timer Counter F (TCF0) module.

Module description

This document contains the implementation of the public and private functions for the Timer Counter F (TCF0) module.

This document contains the API prototypes and data types for the Timer Counter F (TCF0) module.

Version: TCF0 Driver Version 1.0.0
Typedefs
  • typedef void(* TCF0_cb_t) (void)

    Pointer to a function to be used as a callback handler when an overflow interrupt event occurs.

    Used as a callback function pointer.

Definitions
  • #define TCF0_F_US_TO_CLOCKS(US, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(US)) / (2000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from us(microseconds) to clock cycles.

  • #define TCF0_F_MS_TO_CLOCKS(MS, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(MS)) / (2000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from ms(milliseconds) to clock cycles.

  • #define TCF0_F_S_TO_CLOCKS(S, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(S)) / (2.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from seconds to clock cycles.

  • #define TCF0_F_HZ_TO_CLOCKS(HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)((float)(F_CLOCK) / (2.0 * (HZ) * (TCF0_PRESCALER)) - 1)

    Performs the conversion from Hz to clock cycles.

  • #define TCF0_NCOPL_HZ_TO_INCREMENT(HZ, F_CLOCK) (uint32_t)(((float)(HZ) * 16777216.0) / (float)(F_CLOCK) + 0.5)

    Performs the conversion from Hz to Numeric Controlled Oscillator (NCO) increment.

  • #define TCF0_NCOFD_HZ_TO_INCREMENT(HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)(((float)(HZ) * 33554432.0 * (TCF0_PRESCALER)) / ((float)(F_CLOCK)) + 0.5)

    Performs the conversion from Hz to NCO increment.

  • #define TCF0_PWM_PER_HZ_TO_CLOCKS(HZ, F_CLOCK, TCF0_PRESCALER) (uint8_t)((float)(F_CLOCK) / ((float)(TCF0_PRESCALER) * (HZ)) - 1)

    Performs the conversion from Hz to clock cycles.

  • #define TCF0_PWM_PER_US_TO_CLOCKS(US, F_CLOCK, TCF0_PRESCALER) (uint8_t)(((float)(F_CLOCK) * (float)(US)) / (1000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1

    Performs the conversion from ms(microseconds) to clock cycles.

  • #define TCF0_PWM_DCY_TO_CLOCKS(dcy, PER) (uint8_t)(float)((dcy) * (PER))

    Performs the conversion from duty cycle to clock cycles.

Functions
Variables
  • static TCF0_cb_t TCF0_OVF_isr_cb = NULL

    Function pointers that store the callback addresses.

  • static volatile bool timerActive = false

    Boolean that is true when the timer is active.

  • static volatile uint8_t timerMode = TCF_WGMODE_FRQ_gc

    8-bit variable that replicates TCF_WGMODE_t enum to reflect the active mode.

Definition Documentation

TCF0_F_HZ_TO_CLOCKS

#define TCF0_F_HZ_TO_CLOCKS( HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)((float)(F_CLOCK) / (2.0 * (HZ) * (TCF0_PRESCALER)) - 1)

Performs the conversion from Hz to clock cycles.

  • The first argument is the output frequency expressed in Hertz

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in Frequency mode to compute the argument for the TCF0_CompareSet() function.

TCF0_F_MS_TO_CLOCKS

#define TCF0_F_MS_TO_CLOCKS( MS, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(MS)) / (2000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

Performs the conversion from ms(milliseconds) to clock cycles.

  • The first argument is the output period expressed in milliseconds

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in Frequency mode to compute the argument for the TCF0_CompareSet() function.

TCF0_F_S_TO_CLOCKS

#define TCF0_F_S_TO_CLOCKS( S, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(S)) / (2.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

Performs the conversion from seconds to clock cycles.

  • The first argument is the output period expressed in seconds

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in Frequency mode to compute the argument for the TCF0_CompareSet() function.

TCF0_F_US_TO_CLOCKS

#define TCF0_F_US_TO_CLOCKS( US, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(US)) / (2000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

Performs the conversion from us(microseconds) to clock cycles.

Section: Included files Section: TCF0 Macro definitions

  • The first argument is the output period expressed in microseconds

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in Frequency mode to compute the argument for the TCF0_CompareSet() function.

TCF0_NCOFD_HZ_TO_INCREMENT

#define TCF0_NCOFD_HZ_TO_INCREMENT( HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)(((float)(HZ) * 33554432.0 * (TCF0_PRESCALER)) / ((float)(F_CLOCK)) + 0.5)

Performs the conversion from Hz to NCO increment.

  • The first argument is the NCO frequency expressed in Hertz

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in NCO Fixed Duty Cycle mode to compute the argument for the TCF0_CompareSet() function.

TCF0_NCOPL_HZ_TO_INCREMENT

#define TCF0_NCOPL_HZ_TO_INCREMENT( HZ, F_CLOCK) (uint32_t)(((float)(HZ) * 16777216.0) / (float)(F_CLOCK) + 0.5)

Performs the conversion from Hz to Numeric Controlled Oscillator (NCO) increment.

  • The first argument is the NCO frequency expressed in Hertz

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in NCO Pulse Length mode to compute the argument for the TCF0_CompareSet() function.

TCF0_PWM_DCY_TO_CLOCKS

#define TCF0_PWM_DCY_TO_CLOCKS( dcy, PER) (uint8_t)(float)((dcy) * (PER))

Performs the conversion from duty cycle to clock cycles.

  • The first argument is the duty cycle expressed as a real value between 0.0 and 1.0

  • The second argument is an integer expressing the period in clock cycles

Used in PWM mode to compute arguments for the TCF0_PWM_DutyCycle0Set() and TCF0_PWM_DutyCycle1Set() functions.

TCF0_PWM_PER_HZ_TO_CLOCKS

#define TCF0_PWM_PER_HZ_TO_CLOCKS( HZ, F_CLOCK, TCF0_PRESCALER) (uint8_t)((float)(F_CLOCK) / ((float)(TCF0_PRESCALER) * (HZ)) - 1)

Performs the conversion from Hz to clock cycles.

  • The first argument is the Pulse-Width Modulation (PWM) frequency expressed in Hertz

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in PWM mode to compute the argument for the TCF0_PWM_PeriodSet() function.

TCF0_PWM_PER_US_TO_CLOCKS

#define TCF0_PWM_PER_US_TO_CLOCKS( US, F_CLOCK, TCF0_PRESCALER) (uint8_t)(((float)(F_CLOCK) * (float)(US)) / (1000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1

Performs the conversion from ms(microseconds) to clock cycles.

  • The first argument is the PWM period expressed in microseconds

  • The second argument is the TCF peripheral clock frequency expressed in Hertz

  • The third argument is the TCF prescaler value as an integer

Used in PWM mode to compute the argument for the TCF0_PWM_PeriodSet() function.

Typedef Documentation

TCF0_cb_t

typedef void(* TCF0_cb_t) (void)

Pointer to a function to be used as a callback handler when an overflow interrupt event occurs.  

Used as a callback function pointer.

Section: TCF0 Custom data types

Function Documentation

ISR()

ISR (TCF0_INT_vect )

Interrupt Service Routine (ISR).

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_ClockSet()

void TCF0_ClockSet (TCF_CLKSEL_t config)

Sets the clock source for TCF0.

Precondition:

None.

Parameters:
TCF_CLKSEL_t
  • TCF_CLKSEL_CLKPER_gc - Peripheral Clock

  • TCF_CLKSEL_EVENT_gc - Event as clock source

  • TCF_CLKSEL_OSCHF_gc - Internal High Frequency Oscillator

  • TCF_CLKSEL_OSC32K_gc - Internal 32.768 kHz Oscillator

  • TCF_CLKSEL_PLL_gc - PLL

  • TCF_CLKSEL_OSCBOOT_gc - Boot Oscillator

Returns:

None.

TCF0_Compare0CallbackRegister()

void TCF0_Compare0CallbackRegister (TCF0_cb_t cb)

Setter function for TCF0 Capture-Compare0 callback function.

Precondition:

None.

Parameters:
TCF0_cb_t

Pointer to custom callback function.

Returns:

None.

TCF0_Compare1CallbackRegister()

void TCF0_Compare1CallbackRegister (TCF0_cb_t cb)

Setter function for TCF0 Capture-Compare1 callback function.

Precondition:

None.

Parameters:
TCF0_cb_t

Pointer to custom callback function.

Returns:

None.

TCF0_CompareSet()

void TCF0_CompareSet (uint32_t value)

Sets the CMP register value for TCF0.

Precondition:

None.

Parameters:
uint32_t.

Only 24-bit data is used.

Returns:

None.

TCF0_CounterGet()

uint32_t TCF0_CounterGet (void )

Gets the CNT register value.

Precondition:

TCF0_Initialize() is already called.

Parameters:
None.
Returns:

uint32_t.

TCF0_CounterSet()

void TCF0_CounterSet (uint32_t value)

Sets the CNT register value.

Precondition:

None.

Parameters:
uint32_t.

Only 24-bit data is used.

Returns:

None.

TCF0_Deinitialize()

void TCF0_Deinitialize (void )

Resets the TCF0 module to the Default state.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_Event_InputConfig()

void TCF0_Event_InputConfig (uint8_t config)

Configures the input event for TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
uint8_t
where only bits 0-3 are used:
  • Bit 0 enables the event input

  • Bits 1 and 2 select the action event (00 for restart, 01 for blank)

  • Bit 3 enables the filter

Returns:

None.

TCF0_Event_OutputMode()

void TCF0_Event_OutputMode (uint8_t value)

Controls the Event Output mode for TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
uint8_t
where only bits 6-7 are used:
  • Bit 6 represents event output 0

  • Bit 7 represents event output 1

Returns:

None.

TCF0_Initialize()

void TCF0_Initialize (void )

Initializes the TCF0 module and is the first routine called.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_Internal_Start()

inline static void TCF0_Internal_Start (void )

This private function runs the TCF0. It is used only within driver.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_Internal_Stop()

inline static void TCF0_Internal_Stop (void )

This private function stops TCF0. It is used only within driver.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_Interrupts_Disable()

void TCF0_Interrupts_Disable (uint8_t mask)

Disables the TCF0 Overflow, CMP0 or CMP1 interrupts.

Precondition:

TCF0_Initialize() is already called.

Parameters:
uint8_t
where only bits 0-2 are used:
  • Bit 0 disables the OVF interrupt

  • Bit 1 disables the CMP0 interrupt

  • Bit 2 disables the CMP1 interrupt

Returns:

None.

TCF0_Interrupts_Enable()

void TCF0_Interrupts_Enable (uint8_t mask)

Enables the TCF0 Overflow, CMP0 or CMP1 interrupts.

Precondition:

TCF0_Initialize() is already called.

Parameters:
uint8_t
where only bits 0-2 are used:
  • Bit 0 enables the OVF interrupt

  • Bit 1 enables the CMP0 interrupt

  • Bit 2 enables the CMP1 interrupt

Returns:

None.

TCF0_Interrupts_FlagsClear()

void TCF0_Interrupts_FlagsClear (uint8_t mask)

Clears the interrupt flags.

Precondition:

TCF0_Initialize() is already called.

Parameters:
uint8_t
where only bits 0-2 are used:
  • Bit 0 clears the OVF flag

  • Bit 1 clears the CMP0 flag

  • Bit 2 clears the the CMP1 flag

Returns:

None.

TCF0_Interrupts_FlagsGet()

uint8_t TCF0_Interrupts_FlagsGet (void )

Retrieves the interrupt flags.

Precondition:

TCF0_Initialize() is already called.

Parameters:
None.
Returns:

uint8_t  

From the returned 8-bit word, only bits TCF_OVF_bm, TCF_CMP0_bm and TCF_CMP1_bm are used.

TCF0_ModeSet()

void TCF0_ModeSet (TCF_WGMODE_t mode)

Sets the Waveform Generation mode for TCF0.

Precondition:

None.

Parameters:
TCF_WGMODE_t
  • TCF_WGMODE_FRQ_gc - Frequency

  • TCF_WGMODE_NCOPF_gc - NCO Pulse-Frequency

  • TCF_WGMODE_NCOFDC_gc - NCO Fixed Duty Cycle

  • TCF_WGMODE_PWM8_gc - 8-bit PWM

Returns:

None.

TCF0_NCO_PulseLengthSet()

void TCF0_NCO_PulseLengthSet (TCF_WGPULSE_t config)

Sets the pulse length of the generated waveform for TCF0.

Precondition:

None.

Parameters:
TCF_WGPULSE_WIDTH_t
  • TCF_WGPULSE_CLK1_gc - High pulse is 1 clock period

  • TCF_WGPULSE_CLK2_gc - High pulse is 2 clock periods

  • TCF_WGPULSE_CLK4_gc - High pulse is 4 clock periods

  • TCF_WGPULSE_CLK8_gc - High pulse is 8 clock periods

  • TCF_WGPULSE_CLK16_gc - High pulse is 16 clock periods

  • TCF_WGPULSE_CLK32_gc - High pulse is 32 clock periods

  • TCF_WGPULSE_CLK64_gc - High pulse is 64 clock periods

  • TCF_WGPULSE_CLK128_gc - High pulse is 128 clock periods

Returns:

None.

TCF0_OutputsSet()

void TCF0_OutputsSet (uint8_t value)

Controls the Waveform outputs for TCF0.

Precondition:

None.

Parameters:
uint8_t
where only bits 0-3 are used:
  • Bit 0 enables channel 0

  • Bit 1 enables channel 1

  • Bit 2 reverses the polarity on channel 0

  • Bit 3 reverses the polarity on channel 1

Returns:

None.

TCF0_OverflowCallbackRegister()

void TCF0_OverflowCallbackRegister (TCF0_cb_t cb)

Setter function for TCF0 overflow callback.

Section: TCF0 Module APIs

Precondition:

None.

Parameters:
TCF0_cb_t

Pointer to custom callback function.

Returns:

None.

TCF0_PrescalerSet()

void TCF0_PrescalerSet (TCF_PRESC_t config)

Selects the prescaler for TCF0.

Precondition:

None.

Parameters:
TCF_PRESC_t
  • TCF_PRESC_DIV1_gc - direct clock source

  • TCF_PRESC_DIV2_gc - clock speed divided by 2

  • TCF_PRESC_DIV4_gc - clock speed divided by 4

  • TCF_PRESC_DIV8_gc - clock speed divided by 8

  • TCF_PRESC_DIV16_gc - clock speed divided by 16

  • TCF_PRESC_DIV32_gc - clock speed divided by 32

  • TCF_PRESC_DIV64_gc - clock speed divided by 64

  • TCF_PRESC_DIV128_gc - clock speed divided by 128

Returns:

None.

TCF0_PWM_DutyCycle0Set()

void TCF0_PWM_DutyCycle0Set (uint8_t value)

Sets the CMP0 register value for TCF0.

Precondition:

None.

Parameters:
uint8_t.
Returns:

None.

TCF0_PWM_DutyCycle1Set()

void TCF0_PWM_DutyCycle1Set (uint8_t value)

Sets the CMP1 register value for TCF0.

Precondition:

None.

Parameters:
uint8_t.
Returns:

None.

TCF0_PWM_PeriodSet()

void TCF0_PWM_PeriodSet (uint8_t value)

Sets the CNT1 register value for TCF0 in PWM mode.

Precondition:

None.

Parameters:
uint8_t.
Returns:

None.

TCF0_SoftwareCommand()

void TCF0_SoftwareCommand (TCF_CMD_t command)

Issues the software commands of Update, Restart or Reset over the TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
enum
TCF_CMD_t:
  • TCF_CMD_NONE_gc - No command

  • TCF_CMD_UPDATE_gc - Force update

  • TCF_CMD_RESTART_gc - Force restart

Returns:

None.

TCF0_StandBySleep()

void TCF0_StandBySleep (bool state)

Enables or disables the Run-in-Standby mode for TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
boolean
  • True - Enables sleep

  • False - Disables sleep

Returns:

None.

TCF0_Start()

void TCF0_Start (void )

Starts TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
None.
Returns:

None.

TCF0_StatusGet()

TCF0_status_t TCF0_StatusGet (void )

Returns the status of the TCF0 module.

Precondition:

None.

Parameters:
None.
Returns:
enum TCF_status_t:
  • TCF_STATUS_IDLE = 0 - The timer is not running

  • TCF_STATUS_RUNNING = 1 - The timer is running

TCF0_Stop()

void TCF0_Stop (void )

Stops TCF0.

Precondition:

TCF0_Initialize() is already called.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CMP0_IsBusy()

inline static void TCF0_WaitWhile_CMP0_IsBusy (void )

This function blocks the execution until the CMP0 register is no longer busy.

Section: TCF0 Private functions

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CMP1_IsBusy()

inline static void TCF0_WaitWhile_CMP1_IsBusy (void )

This function blocks the execution until the CMP1 register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CNT_IsBusy()

inline static void TCF0_WaitWhile_CNT_IsBusy (void )

This function blocks the execution until the CNT register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CTRLA_IsBusy()

inline static void TCF0_WaitWhile_CTRLA_IsBusy (void )

This function blocks the execution until the CTRLA register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CTRLC_IsBusy()

inline static void TCF0_WaitWhile_CTRLC_IsBusy (void )

This function blocks the execution until the CTRLC register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_CTRLD_IsBusy()

inline static void TCF0_WaitWhile_CTRLD_IsBusy (void )

This function blocks the execution until the CTRLD register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

TCF0_WaitWhile_PER_IsBusy()

inline static void TCF0_WaitWhile_PER_IsBusy (void )

This function blocks the execution until the PER register is no longer busy.

Precondition:

None.

Parameters:
None.
Returns:

None.

Enumeration Type Documentation

TCF0_status_t

enum TCF0_status_t

Lists the possible states of TCF0:

  • TCF_STATUS_IDLE = 0 - The timer is not running

  • TCF_STATUS_RUNNING = 1 - The timer is running

TCF_STATUS_IDLE
TCF_STATUS_RUNNING

Variable Documentation

TCF0_OVF_isr_cb

TCF0_cb_t TCF0_OVF_isr_cb = NULL[static]

Function pointers that store the callback addresses.

Section: Included files Section: TCF0 Private data

timerActive

volatile bool timerActive = false[static]

Boolean that is true when the timer is active.

timerMode

volatile uint8_t timerMode = TCF_WGMODE_FRQ_gc[static]

8-bit variable that replicates TCF_WGMODE_t enum to reflect the active mode.

3.14.8.5 File Documentation

3.14.8.5.1 source/tcf0.c File Reference

#include <avr/interrupt.h>
#include <util/atomic.h>
#include <stddef.h>
#include "tcf0.h"

Functions

Detailed Description

TCF0 Generated Driver API SOURCE File

Variable Documentation

TCF0_CMP0_isr_cb

TCF0_cb_t TCF0_CMP0_isr_cb = NULL[static]

TCF0_CMP1_isr_cb

TCF0_cb_t TCF0_CMP1_isr_cb = NULL[static]

3.14.8.5.2 source/tcf0.h File Reference

#include <stdbool.h>
#include <stdint.h>

Functions

Macros

  • #define TCF0_F_US_TO_CLOCKS(US, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(US)) / (2000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from us(microseconds) to clock cycles.

  • #define TCF0_F_MS_TO_CLOCKS(MS, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(MS)) / (2000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from ms(milliseconds) to clock cycles.

  • #define TCF0_F_S_TO_CLOCKS(S, F_CLOCK, TCF0_PRESCALER) (uint32_t)((((float)(F_CLOCK) * (float)(S)) / (2.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1)

    Performs the conversion from seconds to clock cycles.

  • #define TCF0_F_HZ_TO_CLOCKS(HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)((float)(F_CLOCK) / (2.0 * (HZ) * (TCF0_PRESCALER)) - 1)

    Performs the conversion from Hz to clock cycles.

  • #define TCF0_NCOPL_HZ_TO_INCREMENT(HZ, F_CLOCK) (uint32_t)(((float)(HZ) * 16777216.0) / (float)(F_CLOCK) + 0.5)

    Performs the conversion from Hz to Numeric Controlled Oscillator (NCO) increment.

  • #define TCF0_NCOFD_HZ_TO_INCREMENT(HZ, F_CLOCK, TCF0_PRESCALER) (uint32_t)(((float)(HZ) * 33554432.0 * (TCF0_PRESCALER)) / ((float)(F_CLOCK)) + 0.5)

    Performs the conversion from Hz to NCO increment.

  • #define TCF0_PWM_PER_HZ_TO_CLOCKS(HZ, F_CLOCK, TCF0_PRESCALER) (uint8_t)((float)(F_CLOCK) / ((float)(TCF0_PRESCALER) * (HZ)) - 1)

    Performs the conversion from Hz to clock cycles.

  • #define TCF0_PWM_PER_US_TO_CLOCKS(US, F_CLOCK, TCF0_PRESCALER) (uint8_t)(((float)(F_CLOCK) * (float)(US)) / (1000000.0 * (float)(TCF0_PRESCALER)) + 0.5) - 1

    Performs the conversion from ms(microseconds) to clock cycles.

  • #define TCF0_PWM_DCY_TO_CLOCKS(dcy, PER) (uint8_t)(float)((dcy) * (PER))

    Performs the conversion from duty cycle to clock cycles.

Typedefs

  • typedef void(* TCF0_cb_t) (void)

    Pointer to a function to be used as a callback handler when an overflow interrupt event occurs.  

    Used as a callback function pointer.

Detailed Description

TCF0 Generated Driver API Header File