![]() |
RZT Flexible Software Package Documentation
Release v2.3.0
|
|
Functions | |
fsp_err_t | R_GPT_THREE_PHASE_Open (three_phase_ctrl_t *const p_ctrl, three_phase_cfg_t const *const p_cfg) |
fsp_err_t | R_GPT_THREE_PHASE_Stop (three_phase_ctrl_t *const p_ctrl) |
fsp_err_t | R_GPT_THREE_PHASE_Start (three_phase_ctrl_t *const p_ctrl) |
fsp_err_t | R_GPT_THREE_PHASE_Reset (three_phase_ctrl_t *const p_ctrl) |
fsp_err_t | R_GPT_THREE_PHASE_DutyCycleSet (three_phase_ctrl_t *const p_ctrl, three_phase_duty_cycle_t *const p_duty_cycle) |
fsp_err_t | R_GPT_THREE_PHASE_CallbackSet (three_phase_ctrl_t *const p_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_GPT_THREE_PHASE_Close (three_phase_ctrl_t *const p_ctrl) |
Driver for 3-phase motor control using the GPT peripheral on RZ microprocessor. This module implements the Three-Phase Interface.
The General PWM Timer (GPT) Three-Phase driver provides basic functionality for synchronously starting and stopping three PWM channels for use in 3-phase motor control applications. A function is additionally provided to allow setting duty cycle values for all three channels, optionally with double-buffering.
The GPT Three-Phase driver provides the following functions:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Name | Name must be a valid C symbol | g_three_phase0 | Module name. |
General > Mode |
| Triangle-Wave Symmetric PWM | Mode selection. 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 | 15 | Specify the timer period in units selected below. Setting the period to 0x100000000 raw counts results in the maximum period. Set the period to 0x100000000 raw counts for a free running timer or an input capture configuration. The period can be set up to 0x40000000000, which will use a divider of 1024 with the maximum period. |
General > Period Unit |
| Kilohertz | Unit of the period specified above |
General > GPT U-Unit | Value must be an integer greater than or equal to 0 | 0 | Specify the GPT unit for U signal output. |
General > GPT U-Channel | Value must be an integer greater than or equal to 0 | 0 | Specify the GPT channel for U signal output. |
General > GPT V-Unit | Value must be an integer greater than or equal to 0 | 0 | Specify the GPT unit for V signal output.. |
General > GPT V-Channel | Value must be an integer greater than or equal to 0 | 1 | Specify the GPT channel for V signal output. |
General > GPT W-Unit | Value must be an integer greater than or equal to 0 | 0 | Specify the GPT unit for W signal output. |
General > GPT W-Channel | Value must be an integer greater than or equal to 0 | 2 | Specify the GPT channel for W signal output. |
General > Callback Channel |
| U-Channel | Specify the GPT channel to set a callback for when using R_GPT_THREE_PHASE_CallbackSet. |
General > Buffer Mode |
| Single Buffer | When Double Buffer is selected the 'duty_buffer' array in three_phase_duty_cycle_t is used as a buffer for the 'duty' array. This allows setting the duty cycle for the next two crest/trough events in asymmetric mode with only one call to R_GPT_THREE_PHASE_DutyCycleSet. |
General > GTIOCA Stop Level |
| Pin Level Low | Select the behavior of the output pin when the timer is stopped. |
General > GTIOCB Stop Level |
| Pin Level Low | Select the behavior of the output pin when the timer is stopped. |
Extra Features > Dead Time > Dead Time Count Up (Raw Counts) | Must be a valid non-negative integer with a maximum configurable value of 4294967295 (0xffffffff). | 0 | Select the dead time to apply during up counting. This value also applies during down counting for the GPT32 variants. |
Extra Features > Dead Time > Dead Time Count Down (Raw Counts) | Must be a valid non-negative integer with a maximum configurable value of 4294967295 (0xffffffff). | 0 | Select the dead time to apply during down counting. This value only applies to the GPT32 variants. |
Please refer to the General PWM Timer (r_gpt) section for more information.
Please refer to the General PWM Timer (r_gpt) section for more information.
The following should be configured once the GPT Three-Phase module has been added to a project:
There are two buffering modes available for duty cycle values - single- and double-buffered. In single buffer mode only the values specified in the duty
array element of three_phase_duty_cycle_t are used by R_GPT_THREE_PHASE_DutyCycleSet. At the next trough or crest event the output duty cycle will be internally updated to the set values.
In double buffer mode the duty_buffer
array values are used as buffer values for the duty
elements. Once passed to R_GPT_THREE_PHASE_DutyCycleSet, the next trough or crest event will update the output duty cycle to the values specified in duty
as before. However, at the following crest or trough event the output duty cycle will be updated to the values in duty_buffer
. This allows the duty cycle for both sides of an asymmetric PWM waveform to be set at only one trough or crest event per period instead of at every event.
This is a basic example of minimal use of the GPT Three-Phase module in an application. The duty cycle is updated at every timer trough with the previously loaded buffer value, then the duty cycle buffer is reloaded in the trough interrupt callback.
Data Structures | |
struct | gpt_three_phase_instance_ctrl_t |
struct gpt_three_phase_instance_ctrl_t |
Channel control block. DO NOT INITIALIZE. Initialization occurs when three_phase_api_t::open is called.
fsp_err_t R_GPT_THREE_PHASE_Open | ( | three_phase_ctrl_t *const | p_ctrl, |
three_phase_cfg_t const *const | p_cfg | ||
) |
Initializes the 3-phase timer module (and associated timers) and applies configurations. Implements three_phase_api_t::open.
FSP_SUCCESS | Initialization was successful. |
FSP_ERR_ASSERTION | A required input pointer is NULL. |
FSP_ERR_ALREADY_OPEN | Module is already open. |
fsp_err_t R_GPT_THREE_PHASE_Stop | ( | three_phase_ctrl_t *const | p_ctrl | ) |
Stops all timers synchronously. Implements three_phase_api_t::stop.
FSP_SUCCESS | Timers successfully stopped. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_GPT_THREE_PHASE_Start | ( | three_phase_ctrl_t *const | p_ctrl | ) |
Starts all timers synchronously. Implements three_phase_api_t::start.
FSP_SUCCESS | Timers successfully started. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_GPT_THREE_PHASE_Reset | ( | three_phase_ctrl_t *const | p_ctrl | ) |
Resets the counter values to 0. Implements three_phase_api_t::reset.
FSP_SUCCESS | Counters were reset successfully. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |
fsp_err_t R_GPT_THREE_PHASE_DutyCycleSet | ( | three_phase_ctrl_t *const | p_ctrl, |
three_phase_duty_cycle_t *const | p_duty_cycle | ||
) |
Sets duty cycle for all three timers. Implements three_phase_api_t::dutyCycleSet.
In symmetric PWM mode duty cycle values are reflected after the next trough. In asymmetric PWM mode values are reflected at the next trough OR crest, whichever comes first.
When double-buffering is enabled the values in three_phase_duty_cycle_t::duty_buffer are set to the double-buffer registers. When values are reflected the first time the single buffer values (three_phase_duty_cycle_t::duty) are used. On the second reflection the duty_buffer values are used. In asymmetric PWM mode this enables both count-up and count-down PWM values to be set at trough (or crest) exclusively.
FSP_SUCCESS | Duty cycle updated successfully. |
FSP_ERR_ASSERTION | p_ctrl was NULL |
FSP_ERR_NOT_OPEN | The instance is not opened. |
FSP_ERR_INVALID_ARGUMENT | One or more duty cycle count values was outside the range 0..(period - 1). |
fsp_err_t R_GPT_THREE_PHASE_CallbackSet | ( | three_phase_ctrl_t *const | p_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 for the GPT U-channel with the option to provide memory for the callback argument structure. Implements three_phase_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_GPT_THREE_PHASE_Close | ( | three_phase_ctrl_t *const | p_ctrl | ) |
Stops counters, disables output pins, and clears internal driver data. Implements three_phase_api_t::close.
FSP_SUCCESS | Successful close. |
FSP_ERR_ASSERTION | p_ctrl was NULL. |
FSP_ERR_NOT_OPEN | The instance is not opened. |