![]() |
RZG Flexible Software Package Documentation
Release v3.1.0
|
|
Driver for the MTU3 peripherals on RZ MPUs. This module implements the Timer Interface.
The MTU3 module can be used to measure external input signals, generate a periodic interrupt, or output a periodic or PWM signal to a MTIOC pin.
This module supports the MTU3 peripherals are 16-bit timer and 32-bit timer. All the timer are treated the same in this module from the API perspective.
Device | 16-bit timer | 32-bit timer |
---|---|---|
RZ/G2L | channel 0 to 7 | ch8 |
RZ/G2LC | channel 0 to 5, channel 7 | channel 8 |
RZ/G2UL (Type-1) | channel 0 to 7 | channel 8 |
RZ/G2UL (Type-2) | channel 0 to 5, channel 7 | channel 8 |
RZ/G3S | channel 0 to 7 | channel 8 |
The MTU3 module has the following features:
The following functions are not supported.
RZ MPUs have three timer peripherals: the General PWM Timer (GPT), the General Timer (GTM) and the Multi-Function Timer Pulse Unit 3 (MTU3). When selecting between them, consider these factors:
GPT | GTM | MTU3 | |
---|---|---|---|
Available Channels | It is available all GPT channels supported on each device. | It is available the GTM channels supported on each device. | It is available all MTU3 channels supported on each device. |
Timer Resolution | All MPUs have 32-bit GPT timer. | The GTM timers are 32-bit timers. | All MPUs support 16-bit and 32-bit MTU3 timer. |
Clock Source | The GPT runs off P0 clock with a configurable divider up to 1024. | The GTM runs off P0 clock. | The MTU3 runs off P0 clock with a configurable divider up to 1024. |
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Pin Output Support |
| Disabled | If selected code for outputting a waveform to a pin is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Compare Match > Status |
| Disabled | |
General > Compare Match > Compare match value | Value must be a non-negative integer less than or equal to 0x40000000000 | 0 | Specify the compare match value in units that selected in Period Unit section. |
General > Name | Name must be a valid C symbol | g_timer0 | Module name. |
General > Channel | Enter the supported Channel number | 0 | Specify the hardware channel. |
General > Mode |
| Periodic | Mode selection. Periodic: Generates periodic interrupts or square waves. One-Shot: Generate a single interrupt or a pulse wave. Note: One-Shot mode is implemented in software. ISRs must be enabled for One-Shot even if callback is unused. PWM: Generates basic PWM waveforms. Triangle-Wave Symmetric PWM: Generates symmetric PWM waveforms with duty cycle determined by compare match set during a crest interrupt and updated at the next trough. Triangle-Wave Asymmetric PWM: Generates asymmetric PWM waveforms with duty cycle determined by compare match set during a crest/trough interrupt and updated at the next trough/crest. |
General > Period | Value must be a non-negative integer less than or equal to 0x40000000000 | 0x10000 | Specify the timer period in units selected below. Set the period to 0x100000000 (32-bit) or 0x10000 (16-bit) raw counts. The period can be set up to 0x40000000000 (32-bit) or 0x4000000 (16-bit) which will use a divider of 1024 with the maximum period. 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 generated timer_cfg_t structure. |
General > Period Unit |
| Raw Counts | Unit of the period specified above |
General > Counter Clear Source |
| Disabled | Select counter clear source. |
General > Clock Edge |
| Rising | Select clock edge. |
Output > Duty Cycle Percent (only applicable in PWM mode) | Value must be between 0 and 100 | 50 | Specify the timer duty cycle percent. Only used in PWM mode. |
Output > MTIOCA Output Enabled |
| False | Enable the output of MTIOCA on a pin. |
Output > MTIOCA Stop Level |
| Pin Level Low | Select the behavior of the output pin when the timer is stopped. |
Output > Initial Output Level (only applicable in PWM mode) |
| Pin Level Low | Select the behavior of the output pin after the timer is started. (Set low level duty ratio or high level duty ratio.) |
Output > MTIOCB Output Enabled |
| False | Enable the output of MTIOCB on a pin. |
Output > MTIOCB Stop Level |
| Pin Level Low | Select the behavior of the output pin when the timer is stopped. |
Output > Retain Output Level at Count Stop |
| Disabled | Retain the current MTIOC output level when counting is stopped. |
Input > Phase Count > Bit Mode |
| 16-bit | Select Bit Mode |
Input > Phase Count > Counting Mode | Refer to the RZG Configuration tool for available options. | None | Select Counting Mode |
Input > Phase Count > Clock Pin Select |
| MTCLKA, MTCLKB | Select Clock pin Select |
Input > Input Capture > MTIOCnA Source |
| No Output | Select MTIOCnA Input Capture Source. |
Input > Input Capture > MTIOCnB Source |
| No Output | Select MTIOCnB Input Capture Source. |
Input > Noise Filter > External Clock > Enable |
| Sets the noise filter for the external clock. Since it is a setting common to all channels, it may be overwritten by other Stacks settings. | |
Input > Noise Filter > External Clock > Clock Select |
| P0CLK divided by 1 | Select noise filter clock. |
Input > Noise Filter > Input Capture > Enable |
| Select whether to enable extra features on this channel. | |
Input > Noise Filter > Input Capture > Clock Select |
| P0CLK divided by 1 | Select noise filter clock. |
Custom Waveform > Custom Waveform Enable |
| Disabled | Enable custom waveform configuration. |
Custom Waveform > TGRA(Output Compare or Input Capture Value) | Value must be an integer between 1 and 65536 (0x10000). | 0x10000 | Capture/Compare match A value. In the free-running mode, please set the same value between TGRA and TGRC |
Custom Waveform > TGRB(Output Compare or Input Capture Value) | Value must be an integer between 1 and 65536 (0x10000). | 0x10000 | Capture/Compare match B value. In the free-running mode, please set the same value between TGRB and TGRD |
Custom Waveform > TGRC(The Buffer Value of TGRA) | Value must be an integer between 1 and 65536 (0x10000). | 0x10000 | Capture/Compare match C value. In the free-running mode, please set the same value between TGRA and TGRC |
Custom Waveform > TGRD(The Buffer Value of TGRB) | Value must be an integer between 1 and 65536 (0x10000). | 0x10000 | Capture/Compare match D value. In the free-running mode, please set the same value between TGRB and TGRD |
Custom Waveform > Time Prescaler | Refer to the RZG Configuration tool for available options. | P0CLK divided by 1 (common ch) | Select time prescaler. |
Custom Waveform > MTIOCnA Pin Function |
| No Output | Select TGRA initial output. |
Custom Waveform > MTIOCnB Pin Function |
| No Output | Select TGRB initial output. |
Interrupts > Callback | Name must be a valid C symbol | NULL | A user callback function can be specified here. If this callback function is provided, it will be called from the interrupt service routine (ISR) each time the timer period elapses |
Interrupts > Overflow/Crest Interrupt Enable | MCU Specific Options | Enable the overflow interrupt. | |
Interrupts > Overflow/Crest Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the overflow interrupt priority. This is the crest interrupt for triangle-wave PWM. |
Interrupts > Capture/Compare match A Interrupt Enable | MCU Specific Options | Enable the capture/compare match A interrupt. | |
Interrupts > Capture/Compare match A Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the interrupt priority for capture/compare match A. |
Interrupts > Capture/Compare match B Interrupt Enable | MCU Specific Options | Enable the capture/compare match B interrupt. | |
Interrupts > Capture/Compare match B Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the interrupt priority for capture/compare match B. |
Extra Features > ADC Trigger > Start request cycle A (Start Request Delaying Function) | Must be a valid non-negative integer with a maximum configurable value of 65535 (0xffff). | 0 | Timer A/D Converter start request cycle A (MTU4 or MTU7). |
Extra Features > ADC Trigger > Start request cycle B (Start Request Delaying Function) | Must be a valid non-negative integer with a maximum configurable value of 65535 (0xffff). | 0 | Timer A/D Converter start request cycle B (MTU4 or MTU7). |
Extra Features > ADC Trigger > A/D Converter Activation by TGRA Input Capture/Compare Match Enable |
| Disabled | Select whether to enable A/D Converter Activation by TGRA Input Capture/Compare Match. |
Extra Features > Interrupt Skipping > Group A > Mode |
| Mode 1 | Selects interrupt skipping function 1 or 2(TIMTRA). |
Extra Features > Interrupt Skipping > Group A > TCIV4 Interrupt Skip Count |
| Not skip | Select the number of TCIV4 interrupts to skip. |
Extra Features > Interrupt Skipping > Group A > TCIV3 Interrupt Skip Count |
| Not skip | Select the number of TCIV3 interrupts to skip. |
Extra Features > Interrupt Skipping > Group A > TRG4AN/TRG4BN Interrupt Skip Count |
| Not skip | Select the number of TRG4AN/TRG4BN interrupts to skip. |
Extra Features > Interrupt Skipping > Group B > Mode |
| Mode 1 | Selects interrupt skipping function 1 or 2(TIMTRB). |
Extra Features > Interrupt Skipping > Group B > TCIV7 Interrupt Skip Count |
| Not skip | Select the number of TCIV7 interrupts to skip. |
Extra Features > Interrupt Skipping > Group B > TGIA6 Interrupt Skip Count |
| Not skip | Select the number of TGIA6 interrupts to skip. |
Extra Features > Interrupt Skipping > Group B > TRG7AN/TRG7BN Interrupt Skip Count |
| Not skip | Select the number of TRG7AN/TRG7BN interrupts to skip. |
Extra Features > Extra Features Enable |
| Disabled | Select whether to enable extra features on this channel. |
The MTU3 clock is based on the P0 clock frequency. You can set the P0 clock frequency using the Clocks tab of the Configuration editor.
This module can use MTIOCA and MTIOCB pins as output pins for periodic or PWM signals.
This module can use MTIOCA and MTIOCB as input pins to measure input signals.
The Configuration editor will automatically calculate the period count value and source clock divider based on the selected period time, units and clock speed.
When the selected period unit is "Raw counts", the maximum period setting is 0x40000000000 on a 32-bit timer. This will configure the timer with the maximum period and a count clock divisor of 1024.
The period is updated after the next counter compare match after calling R_MTU3_PeriodSet().
The duty cycle is updated after the next counter compare match after calling R_MTU3_DutyCycleSet().
If changing the period or duty, API need to be called before compare match event occurs for the following reasons:
Avoiding Glitches: If the changes are made after the compare match event has already been scheduled, it could lead to unpredictable behavior or glitches in the output signal. Consistent Output: Making changes before the event ensures that the new settings will be used in the next cycle, providing a smooth transition.
Example: For using Buffer Operation. Figure describe Compare Match B controls the period and Compare Match A controls the duty cycle, and TGRC is the buffer register for TGRA.
.
Be aware that if the interrupt processing time or overhead exceeds the time available to apply the new settings, the updates may not be implemented correctly before the next compare match event. Therefore, users should take interrupt processing time into consider when setting the period and duty cycle.
If changing the period or duty, API need to be called before compare match event occurs.
The MTU3 timer does not support One-Shot mode natively. One-Shot mode is achieved by stopping the timer in the interrupt service routine before the callback is called. If the interrupt is not serviced before the timer period expires again, the timer generates more than one event. The callback is only called once in this case. The output waveform in One-Shot mode is one peripheral clock cycle less than the configured period. The configured period must be at least 2 counts to generate an output pulse.
Examples of One-Shot signals that can be generated by this module are shown below:
The MTIOC pin toggles twice each time the timer expires in periodic mode. This is achieved by defining a PWM wave at a 50 percent duty cycle so that the period of the resulting square wave (from rising edge to rising edge) matches the period of the MTU3 timer. Since the periodic output is actually a PWM output, the time at the stop level is one cycle shorter than the time opposite the stop level for odd period values.
Examples of periodic signals that can be generated by this module are shown below:
For the PWM output signal, the signal level at the start of the cycle and at the end of the cycle (stop_level) can be selected arbitrarily, and can set the initial output level after the count starts. When set to initial output level is high, it generates a PWM waveform with a high level duty ratio, and when set to initial output level is low, it generates a PWM waveform with a low level duty ratio. Also, can be set whether to retain the output compare signal level or to the preset signal level after the count stops.
Examples of PWM signals that can be generated by this module are shown below:
When an interrupt skipping source is selected a hardware counter will increment each time the selected event occurs. Each interrupt past the first (up to the specified skip count) will be suppressed.
Phase count mode is provides 16-bit or 32-bit channels used in phase counting applications. The ability to set the count value of the channel and the function to obtain the count value are possible. In 16-bit mode, only channel 1 and channel 2 can be used. In 32-bit mode, only channel 1 can be set. Since channel 2 is also in use, channel 2 cannot operate in other modes. For information on the operation of each mode of phase counting, refer to the "Phase Counting Mode" in the user's manual. Example of setting for phase counting mode 1 are shown below.
Configuration | Options |
---|---|
General > Channel | - 1 |
General > Mode | - Periodic |
Input > Phase Count > Bit Mode | - 16 bit |
Input > Phase Count > Counting Mode | - Mode 1 |
Count > Phase Count > Pin Clock Select | - MTCLKA, MTCLKB |
This is a basic example of minimal use of the MTU3 in an application.
This is an example of a timer callback.
To use the MTU3 as a free running counter, select periodic mode and set the the Period to 0xFFFF for a 16-bit timer or 0xFFFFFFFF for a 32-bit timer.
This an example of updating the period.
This an example of updating the duty cycle.
This an example of updating the duty cycle and period in the callback function. This example assumes that Compare match B is for setting the period (Count clear source) and Compare match A is for setting the duty cycle.
This example demonstrates the configuration and use of compare match with MTU3 timer.
This is an example of using the MTU3 to capture pulse width or pulse period measurements.
This is an example of using the MTU3 to operate phase counting mode.
Data Structures | |
struct | mtu3_output_pin_t |
struct | mtu3_instance_ctrl_t |
struct | mtu3_extended_pwm_cfg_t |
struct | mtu3_extended_cfg_t |
Enumerations | |
enum | mtu3_io_pin_level_t |
enum | mtu3_clock_edge_t |
enum | mtu3_clock_div_t |
enum | mtu3_tcnt_clear_t |
enum | mtu3_io_pin_t |
enum | mtu3_pin_level_t |
enum | mtu3_noise_filter_t |
enum | mtu3_noise_filter_mtclk_t |
enum | mtu3_noise_filter_clock_t |
enum | mtu3_noise_filter_external_clock_t |
enum | mtu3_interrupt_skip_mode_t |
enum | mtu3_interrupt_skip_count_t |
enum | mtu3_adc_compare_match_t |
enum | mtu3_adc_activation_tgra_compare_match_t |
enum | mtu3_phase_counting_mode_t |
enum | mtu3_bit_mode_t |
enum | mtu3_external_clock_t |
struct mtu3_output_pin_t |
Configurations for output pins.
Data Fields | ||
---|---|---|
mtu3_io_pin_level_t | output_pin_level_a | I/O Control A. |
mtu3_io_pin_level_t | output_pin_level_b | I/O Control B. |
bool | output_enabled_a | Set to true to enable output, false to disable output. |
mtu3_pin_level_t | stop_level_a | Select a stop level from mtu3_pin_level_t. |
mtu3_pin_level_t | initial_level | Select a initial level from mtu3_pin_level_t. |
bool | output_enabled_b | Set to true to enable output, false to disable output. |
mtu3_pin_level_t | stop_level_b | Select a stop level from mtu3_pin_level_t. |
bool | retain_level | Set to true to retain output, false to not retain output. |
struct mtu3_instance_ctrl_t |
Channel control block. DO NOT INITIALIZE. Initialization occurs when timer_api_t::open is called.
Data Fields | |
uint32_t | open |
Whether or not channel is open. | |
const timer_cfg_t * | p_cfg |
Pointer to initial configurations. | |
void * | p_reg |
Base register for this channel. | |
R_MTU_Type * | p_reg_com |
Base register for this channel(common ch) | |
void * | p_reg_nf |
Base register for this channel(noise fileter) | |
uint32_t | channel_mask |
Channel bitmask. | |
bool | oneshot_interrupt_flag |
Interrupt flag when One-Shot mode. | |
uint8_t | tior_ioa |
TIOR.IOA register value. | |
uint8_t | tior_iob |
TIOR.IOB register value. | |
void(* | p_callback )(timer_callback_args_t *) |
Pointer to callback. | |
timer_callback_args_t * | p_callback_memory |
Pointer to optional callback argument memory. | |
void const * | p_context |
Pointer to context to be passed into callback function. | |
struct mtu3_extended_pwm_cfg_t |
MTU3 extension for advanced PWM features.
Data Fields | ||
---|---|---|
mtu3_interrupt_skip_mode_t | interrupt_skip_mode_a | Selects interrupt skipping function 1 or 2(TIMTRA) |
mtu3_interrupt_skip_mode_t | interrupt_skip_mode_b | Selects interrupt skipping function 1 or 2(TIMTRB) |
uint16_t | adc_a_compare_match | Timer A/D Converter Start Request Cycle A (MTU4 or MTU7) |
uint16_t | adc_b_compare_match | Timer A/D Converter Start Request Cycle B (MTU4 or MTU7) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tciv4 | TCIV4 Interrupt Skipping Count Setting(TITCR1A) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tgia3 | TGIA3 Interrupt Skipping Count Setting(TITCR1A) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tciv7 | TCIV7 Interrupt Skipping Count Setting(TITCR1B) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tgia6 | TGIA6 Interrupt Skipping Count Setting(TITCR1B) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tgr4an_bn | TRG4AN/TRG4BN Interrupt Skipping Count Setting(TITCR2A) |
mtu3_interrupt_skip_count_t | interrupt_skip_count_tgr7an_bn | TRG7AN/TRG7BN Interrupt Skipping Count Setting(TITCR2B) |
struct mtu3_extended_cfg_t |
The MTU3 extension constitutes a unique feature of MTU3.
Data Fields | ||
---|---|---|
uint32_t | tgra_val | Capture/Compare match A register. |
uint32_t | tgrb_val | Capture/Compare match B register. |
uint32_t | tgrc_val | Capture/Compare match C register (Does not exist in MTU ch1-2) |
uint32_t | tgrd_val | Capture/Compare match D register (Does not exist in MTU ch1-2) |
mtu3_clock_div_t | mtu3_clk_div | Time Prescaler Select. |
mtu3_clock_edge_t | clk_edge | Clock Edge Select. |
mtu3_tcnt_clear_t | mtu3_clear | Counter Clear Source Select. |
mtu3_output_pin_t | mtioc_ctrl_setting | I/O Control A, B. |
bool | custom_waveform_enabled | |
mtu3_noise_filter_t | noise_filter_mtioc_setting | |
mtu3_noise_filter_clock_t | noise_filter_mtioc_clk | |
mtu3_noise_filter_mtclk_t | noise_filter_mtclk_setting | |
mtu3_noise_filter_external_clock_t | noise_filter_mtclk_clk | |
mtu3_adc_activation_tgra_compare_match_t | adc_activation_setting | |
uint8_t | capture_a_ipl | Capture/Compare match A interrupt priority. |
uint8_t | capture_b_ipl | Capture/Compare match B interrupt priority. |
IRQn_Type | capture_a_irq | Capture/Compare match A interrupt. |
IRQn_Type | capture_b_irq | Capture/Compare match B interrupt. |
mtu3_extended_pwm_cfg_t const * | p_pwm_cfg | Advanced PWM features, optional. |
void * | p_reg | Register base address for specified channel. |
uint32_t | compare_match_value | Storing compare match value for channels. |
uint8_t | compare_match_status | Storing the compare match register status. |
mtu3_phase_counting_mode_t | counting_mode | Select the counting mode. |
mtu3_bit_mode_t | bit_mode | Select bit mode. |
mtu3_external_clock_t | external_clock | Select External Clock Input Pins. |
enum mtu3_io_pin_level_t |
I/O Level Select
enum mtu3_clock_edge_t |
enum mtu3_clock_div_t |
Time Prescaler Select
enum mtu3_tcnt_clear_t |
enum mtu3_io_pin_t |
enum mtu3_pin_level_t |
enum mtu3_noise_filter_t |
Disables or enables the noise filter for input from the MTIOCnA pin
Disables or enables the noise filter for the external clock input pins of the MTU
Number of interrupts to skip between events
enum mtu3_bit_mode_t |
fsp_err_t R_MTU3_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 MTU3 implementation of the general timer can accept a mtu3_extended_cfg_t extension parameter.
Example:
FSP_SUCCESS | Initialization was successful and timer has started. |
FSP_ERR_ASSERTION | A required input pointer is NULL or the source divider is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. |
FSP_ERR_IRQ_BSP_DISABLED | timer_cfg_t::mode is TIMER_MODE_ONE_SHOT or timer_cfg_t::p_callback is not NULL, but ISR is not enabled. ISR must be enabled to use one-shot mode or callback. |
FSP_ERR_INVALID_MODE | Only PERIODIC and PWM are supported. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | The channel requested in the p_cfg parameter is not available on this device. |
fsp_err_t R_MTU3_Stop | ( | timer_ctrl_t *const | p_ctrl | ) |
Stops timer. Implements timer_api_t::stop.
Example:
FSP_SUCCESS | Timer successfully stopped. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_Start | ( | timer_ctrl_t *const | p_ctrl | ) |
Starts timer. Implements timer_api_t::start.
Example:
FSP_SUCCESS | Timer successfully started. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_Reset | ( | timer_ctrl_t *const | p_ctrl | ) |
Resets the counter value to 0. Implements timer_api_t::reset.
FSP_SUCCESS | Counter value written successfully. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_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 compare match. If the timer is stopped, this function resets the counter and updates the period. Implements timer_api_t::periodSet.
Example:
FSP_SUCCESS | Period value written successfully. |
FSP_ERR_ASSERTION | A required pointer was NULL, or the period was not in the valid range of 1 to 0xFFFF. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_DutyCycleSet | ( | timer_ctrl_t *const | p_ctrl, |
uint32_t const | duty_cycle_counts, | ||
uint32_t const | pin | ||
) |
Sets duty cycle. Implements timer_api_t::dutyCycleSet.
Duty cycle is updated in the TGRx register.
[in] | p_ctrl | Pointer to instance control block. |
[in] | duty_cycle_counts | Duty cycle to set in counts. When the initial output setting of the period register is LOW, entering a value greater than the period register will result in a 0% duty cycle. |
[in] | pin | Not Used. |
FSP_SUCCESS | Duty cycle updated successfully. |
FSP_ERR_ASSERTION | A required pointer was NULL, or the period was not in the valid range of 1 to 0xFFFF. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
FSP_ERR_INVALID_ARGUMENT | Duty cycle is larger than period. |
FSP_ERR_UNSUPPORTED | MTU3_CFG_OUTPUT_SUPPORT_ENABLE is 0. |
fsp_err_t R_MTU3_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.
FSP_SUCCESS | TGRx, count direction, frequency, structure successfully. |
FSP_ERR_ASSERTION | p_ctrl or p_info was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_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:
FSP_SUCCESS | Current timer state and counter value set successfully. |
FSP_ERR_ASSERTION | p_ctrl or p_status was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_CounterSet | ( | timer_ctrl_t *const | p_ctrl, |
uint32_t | counter | ||
) |
Set counter value.
FSP_SUCCESS | Counter value updated. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
FSP_ERR_IN_USE | The timer is running. Stop the timer before calling this function. |
fsp_err_t R_MTU3_OutputEnable | ( | timer_ctrl_t *const | p_ctrl, |
mtu3_output_pin_t | pin_level | ||
) |
Enable output for MTIOCA and/or MTIOCB.
FSP_SUCCESS | Output is enabled. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_OutputDisable | ( | timer_ctrl_t *const | p_ctrl, |
mtu3_io_pin_t | pin | ||
) |
Disable output for MTIOCA and/or MTIOCB.
FSP_SUCCESS | Output is disabled. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_Enable | ( | timer_ctrl_t *const | p_ctrl | ) |
Enables external event triggers that capture the counter. Implements timer_api_t::enable.
FSP_SUCCESS | External events successfully enabled. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_Disable | ( | timer_ctrl_t *const | p_ctrl | ) |
Disables external event triggers that capture the counter. Implements timer_api_t::disable.
FSP_SUCCESS | External events successfully disabled. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_AdcTriggerSet | ( | timer_ctrl_t *const | p_ctrl, |
mtu3_adc_compare_match_t | which_compare_match, | ||
uint16_t | compare_match_value | ||
) |
Set A/D converter start request compare match value.
FSP_SUCCESS | Counter value updated. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_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 with the option to provide memory for the callback argument structure. Implements timer_api_t::callbackSet.
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
fsp_err_t R_MTU3_Close | ( | timer_ctrl_t *const | p_ctrl | ) |
Stops counter, disables output pins, and clears internal driver data. Implements timer_api_t::close.
FSP_SUCCESS | Successful close. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_MTU3_CompareMatchSet | ( | timer_ctrl_t *const | p_ctrl, |
uint32_t const | compare_match_value, | ||
timer_compare_match_t const | match_channel | ||
) |
Set value for compare match feature. Implements timer_api_t::compareMatchSet.
Example:
FSP_SUCCESS | Set the compare match value successfully. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |