RA Flexible Software Package Documentation  Release v5.6.0

 
Independent Channel, 16-bit and 8-bit timer (r_tau)

Functions

fsp_err_t R_TAU_Open (timer_ctrl_t *const p_ctrl, timer_cfg_t const *const p_cfg)
 
fsp_err_t R_TAU_Stop (timer_ctrl_t *const p_ctrl)
 
fsp_err_t R_TAU_Start (timer_ctrl_t *const p_ctrl)
 
fsp_err_t R_TAU_Reset (timer_ctrl_t *const p_ctrl)
 
fsp_err_t R_TAU_Enable (timer_ctrl_t *const p_ctrl)
 
fsp_err_t R_TAU_Disable (timer_ctrl_t *const p_ctrl)
 
fsp_err_t R_TAU_PeriodSet (timer_ctrl_t *const p_ctrl, uint32_t const period_counts)
 
fsp_err_t R_TAU_CompareMatchSet (timer_ctrl_t *const p_ctrl, uint32_t const compare_match_value, timer_compare_match_t const match_channel)
 
fsp_err_t R_TAU_DutyCycleSet (timer_ctrl_t *const p_ctrl, uint32_t const duty_cycle_counts, uint32_t const pin)
 
fsp_err_t R_TAU_InfoGet (timer_ctrl_t *const p_ctrl, timer_info_t *const p_info)
 
fsp_err_t R_TAU_StatusGet (timer_ctrl_t *const p_ctrl, timer_status_t *const p_status)
 
fsp_err_t R_TAU_CallbackSet (timer_ctrl_t *const p_api_ctrl, void(*p_callback)(timer_callback_args_t *), void const *const p_context, timer_callback_args_t *const p_callback_memory)
 
fsp_err_t R_TAU_Close (timer_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for the TAU peripheral on RA MCUs. This module implements the Timer Interface.

Overview

Features

The TAU module has the following features:

Channel Interval Timer Square Wave Output External Event Counter DividerInput Pulse Interval Measurement Delay Counter Measure High-Low Level Pulse Width 8-bit timer operation Operation clocks Input signals Output signals
TAU00 CK00, CK01 TI00, ELC TO00
TAU01 CK00, CK01, CK02, CK03 TI01, ELC TO01
TAU02 CK00, CK01 TI02 TO02
TAU03 CK00, CK01, CK02, CK03 TI03 TO03
TAU04 CK00, CK01 TI04 TO04
TAU05 CK00, CK01 TI05, MOCO, LOCO, FSUB TO05
TAU06 CK00, CK01 TI06 TO06
TAU07 CK00, CK01 TI07, RXD2 TO07

Configuration

Build Time Configurations for r_tau

The following build time configurations are defined in fsp_cfg/r_tau_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
Interrupt Support
  • Disabled
  • Enabled
Enabled Enable support for interrupts
Pin Output Support
  • Disabled
  • Enabled
Disabled Enable output for either square wave or divider output
Pin Input Support
  • Disabled
  • Enabled
Disabled Enable input for pulse width measurement, level width measurement, pulse/edge counting or divider functions.
Extra Input Mode Support
  • Disabled
  • Enabled
Disabled Enable support for event counting, system clock count sources and input noise filtering when Pin Input Support is enabled.
8-Bit Mode Support
  • Disabled
  • Enabled
Disabled Enable support for 8-bit timer modes (only available on channels 1 and 3).

Configurations for Timers > Timer, Independent Channel, 16-bit and 8-bit Timer Operation (r_tau)

This module can be added to the Stacks tab via New Stack > Timers > Timer, Independent Channel, 16-bit and 8-bit Timer Operation (r_tau).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_timer0 Module name.
ChannelChannel number must be a non-negative integer0 Physical hardware channel.
Function
  • Interval Timer
  • Square Wave Output
  • External Event Counter
  • Divider
  • Input Pulse Interval Measurement
  • Measure Low Level Pulse Width
  • Measure High Level Pulse Width
  • Delay Counter
Interval Timer Function selection. Note: The calculation of the input pulse function and the high-low level pulse width measurement function is implemented using interrupts. ISR's must be enabled for these functions even if callback is unused.
Bit Timer Mode
  • 16-bit timer
  • Higher 8-bit timer
  • Lower 8-bit timer
  • Higher and Lower 8-bit timer
16-bit timer Specify the 16 or 8-bit timer mode
Operation Clock
  • CK00
  • CK01
  • CK02
  • CK03
CK00 Specify the selection of operation clock
PeriodValue must be a non-negative integer0x10000 Specify the timer period based on the selected units.

When the unit is set to 'Raw Counts', setting the period to 0x10000 results in the maximum period at the lowest divisor (fastest timer tick). When Pulse width measurement or high-low level pulse width measurement is enabled, this period is always generated as zero.. The period should be set maximally 0x100 when lower 8-bit mode or higher and lower 8-bit mode is enabled.
When 'Input->Trigger Edge' is set to 'Trigger Edge Rising' or 'Trigger Edge Falling', this period can be maximally set to 0x20000 when using the divider function.

If the requested period cannot be achieved, the settings with the largest possible period, that does not exceed the requested period, are used. The theoretical calculated period is printed in a comment in the timer_cfg_t structure.
Period Unit
  • Raw Counts
  • Nanoseconds
  • Microseconds
  • Milliseconds
  • Seconds
  • Hertz
  • Kilohertz
Raw Counts Unit of the period specified above
Period (Higher 8-bit timer)Value must be a non-negative integer0x100 Specify the higher 8-bit timer period based on the selected unit.

When the unit is set to 'Raw Counts', setting the period to 0x100 results in the maximum period at the lowest divisor (fastest timer tick). This setting is only applicable in interval timer function with higher 8bit mode or higher and lower 8bit mode.

If the requested period cannot be achieved, the settings with the largest possible period that is less than or equal to the requested period are used. The theoretical calculated period is printed in a comment in the tau_extended_cfg_t structure.
Period Unit (Higher 8-bit timer)
  • Raw Counts
  • Nanoseconds
  • Microseconds
  • Milliseconds
  • Seconds
  • Hertz
  • Kilohertz
Raw Counts Unit of the period specified above
Input
Input SourceMCU Specific OptionsInput source, applies in input pulse width measurement function, high-low level pulse width measurement function, external event count function, and divider function.
Trigger Edge
  • Trigger Edge Rising
  • Trigger Edge Falling
  • Trigger Edge Both
Trigger Edge Rising Select the trigger edge. Applies in input pulse width measurement function, high-low level pulse width measurement function, external event count function, and divider function.
Input Filter
  • Disabled
  • Enabled
Disabled Input filter, applies in input pulse width measurement function, high-low level pulse width measurement function, external event count function, and divider function.
Output
Initial Output
  • Disabled
  • Start Level High
  • Start Level Low
Disabled Initial output, applies in divider function and square wave.
Interrupts
Setting of starting count and interrupt
  • Timer interrupt is not generated when counting is started/Start trigger is invalid during counting operation.
  • Timer interrupt is generated when counting is started/Start trigger is valid during counting operation.
Timer interrupt is not generated when counting is started/Start trigger is invalid during counting operation. Specify OPIRQ bit setting
CallbackName must be a valid C symbolNULL A user callback function. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the timer period elapses.
Interrupt PriorityMCU Specific OptionsTimer interrupt priority.
Higher 8-bit Interrupt PriorityMCU Specific OptionsTimer higher 8-bit interrupt priority.

Clock Configuration

The TAU clock is based on the peripheral module clock (PCLKB) which is equal to the system clock (ICLK).

Each TAU channel has certain operation clocks selections, these can be set with the General>Operation Clock property in the module configuration. When the operation clock of a channel is set to CK00, CK01, CK02, or CK03, the TAU module provides divisor values for each of those clocks. These divisors may be set in the Clocks tab. As such, setting a divisor in the Clocks tab affects all TAU channels that use that CK0x clock as an input. Adjusting these settings determines the frequency range achievable by a TAU channel. If a desired frequency is not achievable, the divider in the Clocks tab may be adjusted. The clock dividers cannot be adjusted at runtime.

Pin Configuration

This module should use the TOmn pins as output pins for Square Wave Output, Divider Function

For input source, the input signal must be applied to External Event Counter, Divider, Input Pulse Interval Measurement, Delay Counter, and Measure High-Low Level Pulse Width Function

Timer Period

The RA Configuration editor will automatically calculate the period count value based on the selected period time, units, operation clock (set by General>Operation Clock property in the module configuration), and clock divisor value (set in Clocks tab).

When the selected unit is "Raw counts", the maximum and minimum allowed period setting varies depending on the selected clock source:

Clock divisor Minimum period (counts) Maximum period (counts)
ICLK/1 0x00002 0x10000
All other divisors 0x00001 0x10000
Note
If ICLK (undivided) is selected as the operation clock (CK00, CK01) and TDR0n is set to 0x0000 (n = 0 to 7), interrupt requests output from timer array units cannot be used. For this reason When Clock Source is ICLK, Minimum period (counts) is 0x00002
Clock divisor Minimum Higher 8-bit period (counts) Maximum Higher 8-bit period (counts)
All divisors 0x001 0x100
Note
Though the TAU is a 16-bit timer, because the period interrupt occurs when the counter underflow, setting the period register to 0 results in an effective period of 1 count. For this reason all user-provided raw count values reflect the actual number of period counts (not the raw register values).

Usage Notes

Interval Timer Function

This function can be used as a reference timer to generate TAU0_TMI0n (timer interrupt) at fixed intervals. The interrupt generation period can be calculated by the following expression.

The Interval Timer Function can operate as the higher/lower 8-bits mode.

When "Interrupts > Setting of starting count and interrupt" is "Timer interrupt is generated when counting is started/Start trigger is valid during counting operation.", an interrupt is generated immediately after R_TAU_Start() function is called and timer output also changed.

Square Wave Output Function

This function can use TO0n to perform a toggle operation as soon as TAU0_TMI0n has been generated, and outputs a square wave with a duty factor of 50%.

The period and frequency for outputting a square wave from TO0n can be calculated by the following expressions.

The Square Wave Output Function can operate as the lower 8-bits mode.

When "Interrupts > Setting of starting count and interrupt" is "Timer interrupt is generated when counting is started/Start trigger is valid during counting operation.", an interrupt is generated immediately after R_TAU_Start() function is called and output pin is also changed.

External Event Counter Function

The timer array unit can be used as an external event counter that counts the number of times the valid input edge (external event) is detected in the TI0n pin. When a specified count value is reached, the event counter generates an interrupt. The specified number of counts can be calculated by the following expression.

Instead of using the TI0n pin input, a channel specified for the External Event Counter Function can also use the signal as "Middle-speed on-chip oscillator (MOCO)", "Low-speed on-chip oscillator (LOCO)", "Subsystem clock (FSUB)", and ELC event which selected in Input>Input Source property as its input source to drive counting.

The External Event Counter Function can operate as the lower 8-bits mode.

Delay Counter Function

It is possible to start counting down when the valid edge of the TI0n pin input is detected (an external event), and then generate TAU0_TMI0n (a timer interrupt) after any specified interval. The interrupt generation period can be calculated by the following expression. Generation period of TAU0_TMI0n (timer interrupt) = Period of count clock × (Set value of TDR0n + 1)

Instead of using the TI0n pin input, a channel specified for the Delay Counter Function can also use the signal as "Middle-speed on-chip oscillator (MOCO)", "Low-speed on-chip oscillator (LOCO)", "Subsystem clock (FSUB)", and ELC event which selected in Input>Input Source property as its input source to drive counting.

The Delay Counter Function can operate as the lower 8-bits mode.

When "Interrupts > Setting of starting count and interrupt" is "Timer interrupt is generated when counting is started/Start trigger is valid during counting operation.", a start trigger is valid during counting operation.

Divider Function

The timer array unit can be used as a frequency divider that divides a clock input to the TI00 pin and outputs the result from the TO00 pin. The divided clock frequency output from TO00 can be calculated by the following expression. When rising edge/falling edge is selected:

When "Interrupts > Setting of starting count and interrupt" is "Timer interrupt is generated when counting is started/Start trigger is valid during counting operation.", an interrupt is generated immediately after first input signal is detected and output pin is also changed.

Input Pulse Interval Measurement Function

The count value can be captured at the TI0n valid edge and the interval of the pulse input to TI0n can be measured. The pulse interval can be calculated by the following expression.

Instead of using the TI0n pin input, a channel specified for the Input Pulse Interval Measurement can also use the signal as "Middle-speed on-chip oscillator (MOCO)", "Low-speed on-chip oscillator (LOCO)", "Subsystem clock (FSUB)", "Input signal of the RXD2 pin", and ELC event which selected in Input>Input Source property as its input source to drive counting.

High-Low Level Pulse Width Measurement

By starting counting at one edge of the TI0n pin input and capturing the number of counts at another edge, the signal width (high-level width or low-level width) of TI0n can be measured. The signal width of TI0n can be calculated by the following expression.

Instead of using the TI0n pin input, a channel specified for the High-Low Level Pulse Width Function can also use the signal as "Middle-speed on-chip oscillator (MOCO)", "Low-speed on-chip oscillator (LOCO)", "Subsystem clock (FSUB)", "Input signal of the RXD2 pin", and ELC event which selected in Input>Input Source property as its input source to drive counting.

Triggering ELC Events with TAU

The TAU timer can trigger the start of other peripherals. The Event Link Controller (r_elc) guide provides a list of all available peripherals.

Limitations

Examples

TAU Basic Example

This is a basic example of minimal use of the TAU in an application.

void tau_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_TAU_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_TAU_Start(&g_timer0_ctrl);
}

TAU Callback Example

This is an example of a timer callback.

/* Example callback called when timer expires. */
uint32_t g_counter_underflow = 0U;
void timer_callback (timer_callback_args_t * p_args)
{
if (TIMER_EVENT_CYCLE_END == p_args->event)
{
/* Add application code to be called periodically here. */
g_counter_underflow++;
}
{
/* Add application code to be called periodically here. */
}
}

TAU 16-bit or 8-bit mode Example

To use the TAU as 16-bit or 8-bit mode, select Bit Mode Timer.

void tau_counter_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_TAU_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_TAU_Start(&g_timer0_ctrl);
/* (Optional) Stop the timer. */
(void) R_TAU_Stop(&g_timer0_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer0_ctrl, &status);
}
void tau_higher_8bit_counter_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_TAU_Open(&g_timer0_ctrl, &g_timer0_higher_8bit_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_TAU_Start(&g_timer0_ctrl);
/* (Optional) Stop the timer. */
(void) R_TAU_Stop(&g_timer0_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer0_ctrl, &status);
}

TAU Input Capture Example

This is an example of using the TAU to capture pulse width or pulse period measurements.

/* Example callback called when a capture occurs. */
uint32_t g_captured_time = 0U;
void timer_capture_callback (timer_callback_args_t * p_args)
{
{
/* Process capture from TAUIO. */
g_captured_time = p_args->capture;
}
}
void tau_input_capture_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_TAU_Open(&g_timer_input_capture_ctrl, &g_timer_input_capture_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Enable captures. Captured values arrive in the interrupt. */
(void) R_TAU_Enable(&g_timer_input_capture_ctrl);
/* (Optional) Disable captures. */
(void) R_TAU_Disable(&g_timer_input_capture_ctrl);
}

TAU Period Update Example

This is an example of updating the period.

#define TAU_EXAMPLE_MSEC_PER_SEC (1000)
#define TAU_EXAMPLE_DESIRED_PERIOD_MSEC (20)
/* This example shows how to calculate a new period value at runtime. */
void tau_period_calculation_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_TAU_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_TAU_Start(&g_timer0_ctrl);
/* Get operation clock frequency
* - Use the R_TAU_InfoGet function (it accounts for the clock source and divider of operation clock ).
*/
(void) R_TAU_InfoGet(&g_timer0_ctrl, &info);
uint32_t timer_freq_hz = info.clock_frequency;
/* Calculate the desired period based on the current clock. Note that this calculation could overflow if the
* desired period is larger than UINT32_MAX / iclk_freq_hz. A cast to uint32_t is used to prevent this. */
uint32_t period_counts =
(uint32_t) ((timer_freq_hz * TAU_EXAMPLE_DESIRED_PERIOD_MSEC) / TAU_EXAMPLE_MSEC_PER_SEC);
/* Set the calculated period. This will return an error if parameter checking is enabled and the calculated
* period is larger than UINT16_MAX. */
err = R_TAU_PeriodSet(&g_timer0_ctrl, period_counts);
assert(FSP_SUCCESS == err);
}

TAU Square Wave Output Function Example

This is an example of configuration for Square Wave Output Function.

/* This example shows how configure squarewave output function. */
void tau_squarewave_output_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initialize the timers. */
err = R_TAU_Open(&g_timer_squarewave_ctrl, &g_timer_squarewave_cfg);
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_TAU_Start(&g_timer_squarewave_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer_squarewave_ctrl, &status);
}

TAU External Event Counter Function Example

This is an example of configuration for External Event Counter Function.

/* This example shows how to configure the external event counter function. */
void tau_external_event_counter_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initialize the timers. */
err = R_TAU_Open(&g_timer_external_event_ctrl, &g_timer_external_event_cfg);
assert(FSP_SUCCESS == err);
/* Enable external event counter */
(void) R_TAU_Enable(&g_timer_external_event_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer_external_event_ctrl, &status);
}

TAU Divider Function Example

This is an example of configuration for Divider Function.

/* This example shows how configure divider function. */
void tau_divider_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initialize the timers. */
err = R_TAU_Open(&g_timer_divider_ctrl, &g_timer_divider_cfg);
assert(FSP_SUCCESS == err);
/* Start the divider. */
(void) R_TAU_Start(&g_timer_divider_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer_divider_ctrl, &status);
}

TAU Delay Counter Function Example

This is an example of configuration for Delay Counter Function.

/* This example shows how configure delay counter function. */
void tau_delay_counter_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initialize the timers. */
err = R_TAU_Open(&g_timer_delay_counter_ctrl, &g_timer_delay_counter_cfg);
assert(FSP_SUCCESS == err);
/* Start Delay Counter. */
(void) R_TAU_Enable(&g_timer_delay_counter_ctrl);
/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer_delay_counter_ctrl, &status);
}

Data Structures

struct  tau_instance_ctrl_t
 
struct  tau_extended_cfg_t
 

Enumerations

enum  tau_function_t
 
enum  tau_bit_mode_t
 
enum  tau_operation_ck_t
 
enum  tau_trigger_edge_t
 
enum  tau_interrupt_opirq_bit_t
 
enum  tau_input_source_t
 
enum  tau_pin_output_cfg_t
 
enum  tau_input_noise_filter_t
 

Data Structure Documentation

◆ tau_instance_ctrl_t

struct tau_instance_ctrl_t

Channel control block. DO NOT INITIALIZE. Initialization occurs when timer_api_t::open is called.

◆ tau_extended_cfg_t

struct tau_extended_cfg_t

Optional TAU extension data structure.

Data Fields
tau_interrupt_opirq_bit_t opirq: 1 Setting of starting count and interrupt.
tau_function_t tau_func Setting of Function for TAU.
tau_bit_mode_t bit_mode Setting of 16-bit timer or 8-bit timer.
tau_pin_output_cfg_t initial_output Setting of Function for TAU.
tau_input_source_t input_source
tau_input_noise_filter_t tau_filter Input filter for TAU.
tau_trigger_edge_t trigger_edge Trigger edge to start pulse period measurement or count external event.
tau_operation_ck_t operation_clock
uint16_t period_higher_8bit_counts Period in raw higher 8 bit timer counts.
uint8_t higher_8bit_cycle_end_ipl Cycle higher 8-bit end interrupt priority.
IRQn_Type higher_8bit_cycle_end_irq Cycle higher 8-bit end interrupt.

Enumeration Type Documentation

◆ tau_function_t

Timer function

Enumerator
TAU_FUNCTION_INTERVAL 

Interval Timer Function.

TAU_FUNCTION_SQUARE_WAVE 

Square Wave Function.

TAU_FUNCTION_EXTERNAL_EVENT_COUNT 

External Event Count Function.

TAU_FUNCTION_DIVIDER 

Divider Function.

TAU_FUNCTION_INPUT_PULSE_INTERVAL_MEASUREMENT 

Input Pulse Interval Function.

TAU_FUNCTION_LOW_LEVEL_WIDTH_MEASUREMENT 

Low Level Width Measure Function.

TAU_FUNCTION_HIGH_LEVEL_WIDTH_MEASUREMENT 

High Level Width Measure Function.

TAU_FUNCTION_DELAY_COUNT 

Delay Count Function.

◆ tau_bit_mode_t

Timer bit mode

Enumerator
TAU_BIT_MODE_16BIT 

16-Bit Timer Mode

TAU_BIT_MODE_HIGHER_8BIT 

Higher 8-bit Timer Mode.

TAU_BIT_MODE_LOWER_8BIT 

Lower 8-bit Timer Mode.

TAU_BIT_MODE_HIGHER_LOWER_8BIT 

Lower and Higher 8-bit Timer Mode.

◆ tau_operation_ck_t

Timer operation clock.

◆ tau_trigger_edge_t

Trigger edge for pulse period measurement mode, high-low measurement, divider, delay counter and event counting mode.

Enumerator
TAU_TRIGGER_EDGE_FALLING 

Measurement starts or events are counted on falling edge.

TAU_TRIGGER_EDGE_RISING 

Measurement starts or events are counted on rising edge.

TAU_TRIGGER_EDGE_BOTH 

Events are counted on both edges (pulse period mode and high-low measurement)

◆ tau_interrupt_opirq_bit_t

Interrupt and starting Count Mode

◆ tau_input_source_t

Input source

Enumerator
TAU_INPUT_SOURCE_TI_PIN 

Timer Input Source is input pin.

TAU_INPUT_SOURCE_ELC 

ELC Timer Input Source.

TAU_INPUT_SOURCE_RXD2_PIN 

Timer Input Source is RXD2 pin.

TAU_INPUT_SOURCE_MOCO 

Timer Input Source is MOCO.

TAU_INPUT_SOURCE_LOCO 

Timer Input Source is LOCO.

TAU_INPUT_SOURCE_FSUB 

Timer Input Source is FSUB.

TAU_INPUT_SOURCE_NONE 

No Timer Input Source.

◆ tau_pin_output_cfg_t

Level of TAU pin

Enumerator
TAU_PIN_OUTPUT_CFG_START_LEVEL_LOW 

Pin level low.

TAU_PIN_OUTPUT_CFG_START_LEVEL_HIGH 

Pin level high.

TAU_PIN_OUTPUT_CFG_DISABLED 

Not used as output pin.

◆ tau_input_noise_filter_t

Input filter, applies TAU in high-low measurement, pulse width measurement, delay counter, divider, or event counter mode.

Enumerator
TAU_INPUT_NOISE_FILTER_DISABLE 

Disable noise filter.

TAU_INPUT_NOISE_FILTER_ENABLE 

Enable noise filter.

Function Documentation

◆ R_TAU_Open()

fsp_err_t R_TAU_Open ( timer_ctrl_t *const  p_ctrl,
timer_cfg_t const *const  p_cfg 
)

Initializes the timer module and applies configurations. Implements timer_api_t::open.

The TAU implementation of the general timer can accept a tau_extended_cfg_t extension parameter.

Example:

/* Initializes the module. */
err = R_TAU_Open(&g_timer0_ctrl, &g_timer0_cfg);
Return values
FSP_SUCCESSInitialization was successful and timer has started.
FSP_ERR_ASSERTIONA required input pointer is NULL or the period is not in the valid range
FSP_ERR_ALREADY_OPENModule is already open.
FSP_ERR_INVALID_CHANNELThe channel does not support this feature.
FSP_ERR_IRQ_BSP_DISABLEDTimer_cfg_t::p_callback is not NULL, but ISR is not enabled. ISR must be enabled to use callback
FSP_ERR_INVALID_MODEInvalid configuration for p_extend.
FSP_ERR_IP_CHANNEL_NOT_PRESENTThe channel requested in the p_cfg parameter is not available on this device.

◆ R_TAU_Stop()

fsp_err_t R_TAU_Stop ( timer_ctrl_t *const  p_ctrl)

Stops timer. Implements timer_api_t::stop.

Example:

/* (Optional) Stop the timer. */
(void) R_TAU_Stop(&g_timer0_ctrl);
Return values
FSP_SUCCESSTimer successfully stopped.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_Start()

fsp_err_t R_TAU_Start ( timer_ctrl_t *const  p_ctrl)

Starts timer. Implements timer_api_t::start.

Example:

/* Start the timer. */
(void) R_TAU_Start(&g_timer0_ctrl);
Return values
FSP_SUCCESSTimer successfully started.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_Reset()

fsp_err_t R_TAU_Reset ( timer_ctrl_t *const  p_ctrl)

Resets the counter value to the period minus one. Input Pulse Function is reset counter value to 0. Implements timer_api_t::reset.

Note
This function can not reset the counter when counter is stopped, and function High/Low Measurement Function is used.
Return values
FSP_SUCCESSThe counter value written successfully.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_Enable()

fsp_err_t R_TAU_Enable ( timer_ctrl_t *const  p_ctrl)

Enables external event triggers that start, stop, clear, or capture the counter. Implements timer_api_t::enable.

Example:

/* Enable captures. Captured values arrive in the interrupt. */
(void) R_TAU_Enable(&g_timer_input_capture_ctrl);
Return values
FSP_SUCCESSExternal events successfully enabled.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_Disable()

fsp_err_t R_TAU_Disable ( timer_ctrl_t *const  p_ctrl)

Disables external event triggers that start, stop, clear, or capture the counter. Implements timer_api_t::disable.

Note
The timer could be running after R_TAU_Disable(). To ensure it is stopped, call R_TAU_Stop().

Example:

/* (Optional) Disable captures. */
(void) R_TAU_Disable(&g_timer_input_capture_ctrl);
Return values
FSP_SUCCESSExternal events successfully disabled.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_PeriodSet()

fsp_err_t R_TAU_PeriodSet ( timer_ctrl_t *const  p_ctrl,
uint32_t const  period_counts 
)

Sets period value provided. If the timer is running, the period will be updated after the next counter underflow. If the timer is stopped, this function resets the counter and updates the period. This Function is not supported for Input pulse Function, High-Low Measurement Function. Implements timer_api_t::periodSet.

Note
if timer mode is Lower and Higher 8-bit Timer Mode, the last 8 bits are the lower 8-bits of the timer, and the subsequent 8 bits are the higher 8-bits of the timer

Example:

/* Get operation clock frequency
* - Use the R_TAU_InfoGet function (it accounts for the clock source and divider of operation clock ).
*/
(void) R_TAU_InfoGet(&g_timer0_ctrl, &info);
uint32_t timer_freq_hz = info.clock_frequency;
/* Calculate the desired period based on the current clock. Note that this calculation could overflow if the
* desired period is larger than UINT32_MAX / iclk_freq_hz. A cast to uint32_t is used to prevent this. */
uint32_t period_counts =
(uint32_t) ((timer_freq_hz * TAU_EXAMPLE_DESIRED_PERIOD_MSEC) / TAU_EXAMPLE_MSEC_PER_SEC);
/* Set the calculated period. This will return an error if parameter checking is enabled and the calculated
* period is larger than UINT16_MAX. */
err = R_TAU_PeriodSet(&g_timer0_ctrl, period_counts);
assert(FSP_SUCCESS == err);
Return values
FSP_SUCCESSPeriod value written successfully.
FSP_ERR_ASSERTIONp_ctrl was NULL or period is invalid range.
FSP_ERR_NOT_OPENThe instance is not opened.
FSP_ERR_UNSUPPORTEDUnsupported for Input pulse Function, High-Low Measurement Function

◆ R_TAU_CompareMatchSet()

fsp_err_t R_TAU_CompareMatchSet ( timer_ctrl_t *const  p_ctrl,
uint32_t const  compare_match_value,
timer_compare_match_t const  match_channel 
)

Placeholder for unsupported compareMatch function. Implements timer_api_t::compareMatchSet.

Return values
FSP_ERR_UNSUPPORTEDTAU compare match is not supported.

◆ R_TAU_DutyCycleSet()

fsp_err_t R_TAU_DutyCycleSet ( timer_ctrl_t *const  p_ctrl,
uint32_t const  duty_cycle_counts,
uint32_t const  pin 
)

timer_api_t::dutyCycleSet is not supported on the R_TAU Independent channels.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_TAU_InfoGet()

fsp_err_t R_TAU_InfoGet ( timer_ctrl_t *const  p_ctrl,
timer_info_t *const  p_info 
)

Get timer information and store it in provided pointer p_info. Implements timer_api_t::infoGet.

Example:

(void) R_TAU_InfoGet(&g_timer0_ctrl, &info);
uint32_t timer_freq_hz = info.clock_frequency;
Return values
FSP_SUCCESSPeriod, count direction, frequency, and ELC event written to caller's structure successfully.
FSP_ERR_ASSERTIONp_ctrl or p_info was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_StatusGet()

fsp_err_t R_TAU_StatusGet ( timer_ctrl_t *const  p_ctrl,
timer_status_t *const  p_status 
)

Get current timer status and store it in provided pointer p_status. Implements timer_api_t::statusGet.

Example:

/* Read the current counter value. Counter value is in status.counter. */
(void) R_TAU_StatusGet(&g_timer0_ctrl, &status);
Return values
FSP_SUCCESSCurrent timer state and counter value set successfully.
FSP_ERR_ASSERTIONp_ctrl or p_status was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.

◆ R_TAU_CallbackSet()

fsp_err_t R_TAU_CallbackSet ( timer_ctrl_t *const  p_api_ctrl,
void(*)(timer_callback_args_t *)  p_callback,
void const *const  p_context,
timer_callback_args_t *const  p_callback_memory 
)

Updates the user callback. Implements timer_api_t::callbackSet.

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.

◆ R_TAU_Close()

fsp_err_t R_TAU_Close ( timer_ctrl_t *const  p_ctrl)

Stops counter, disables output pins, and clears internal driver data. Implements timer_api_t::close.

Return values
FSP_SUCCESSSuccessful close.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance is not opened.