RA Flexible Software Package Documentation
Release v5.6.0
|
|
Functions | |
fsp_err_t | R_IIRFA_Open (iir_ctrl_t *const p_api_ctrl, iir_cfg_t const *const p_cfg) |
fsp_err_t | R_IIRFA_Filter (iir_ctrl_t *const p_api_ctrl, float const *p_data_in, float *p_data_out, uint16_t const num_samples) |
fsp_err_t | R_IIRFA_Configure (iir_ctrl_t *const p_api_ctrl, iir_filter_cfg_t const *const p_filter_cfg) |
fsp_err_t | R_IIRFA_StatusGet (iir_ctrl_t *const p_api_ctrl, iir_status_t *const p_status) |
fsp_err_t | R_IIRFA_Close (iir_ctrl_t *const p_api_ctrl) |
__STATIC_INLINE float | R_IIRFA_SingleFilter (iir_ctrl_t *const p_api_ctrl, float data_in) |
Driver for the IIRFA peripheral on RA MCUs. This module implements the IIR Interface.
The IIR Filter Accelerator (IIRFA) provides hardware acceleration for calculation of single-precision floating point direct form 2 biquad IIR filters. Up to 32 biquad stages can be configured at a time.
The IIRFA module supports the following features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Polling Mode |
| Enabled | When enabled the IIRFA driver will poll for completion before reading the output register. This prevents IIRFA operations from delaying global interrupt processing at the cost of slower filter performance. |
Software Loop Unroll Depth | Refer to the RA Configuration tool for available options. | 1 Sample | Select the number of samples to process for every loop. This setting generally only affects filters that use 1 biquad stage. |
ECC Support |
| Enabled | Select whether to detect ECC errors. When set to 'Enabled (no writeback)' 1-bit ECC errors will not be corrected. |
Rounding Mode |
| Nearest | Select how to round calculation results. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_iirfa0 | Module name. |
Channel | Value must be an integer between 0 and 15 | 0 | Select the IIRFA channel. |
The clock source for the IIRFA peripheral is ICLK.
IIRFA does not have any pin connections.
Before using IIRFA to filter data the coefficients and state variables must be initialized. See the Filter Configuration example for how to initialize an iir_filter_cfg_t struct to pass to R_IIRFA_Configure.
The optimum configuration for IIRFA is dependent on the application. It is recommended to consider the following in regards to your project to determine what settings may be ideal.
Regardless of configuration, each filter stage takes 2 ICLK cycles to process per sample and an additional 5 cycles to write state values back to registers. This means single-sample operations only take 2 cycles per stage while multi-sample operations take 7. Additional overhead cycles are required to load and store each sample. The following suggestions may improve performance:
By default, the driver will poll a status flag for completion after writing input data to IIRFA. Disabling polling significantly improves performance when using a low number of stages, but may cause higher global interrupt latency during processing.
arm_biquad_cascade_df2T_init_f32
and arm_biquad_cascade_df2T_f32
may provide better performance. It up to the user to evaluate performance within their own project.In applications such as motor control where each sample needs immediate processing, the inline function R_IIRFA_SingleFilter is provided. This function has no parameter checking, takes one sample, and returns a filtered sample. Polling is supported by this function (if configured).
If configured, R_IIRFA_Filter will return an error if a 1- or 2-bit ECC error has occurred.
1-bit errors are automatically corrected unless writeback is disabled. 2-bit errors cannot be automatically corrected. Reset the coefficient and filter data by calling R_IIRFA_Configure if a non-correctable ECC error is reported.
Below is an example of how to initialize a filter configuration to pass to R_IIRFA_Configure.
The following is a basic example of configuring and using a filter with IIRFA.
Data Structures | |
struct | iirfa_instance_ctrl_t |
struct iirfa_instance_ctrl_t |
IIRFA instance control block.
fsp_err_t R_IIRFA_Open | ( | iir_ctrl_t *const | p_api_ctrl, |
iir_cfg_t const *const | p_cfg | ||
) |
Prepare an IIR channel for filtering.
FSP_SUCCESS | The channel was successfully opened. |
FSP_ERR_ASSERTION | One or both of the parameters was NULL. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | An invalid channel was selected. |
FSP_ERR_ALREADY_OPEN | The instance is already opened. |
fsp_err_t R_IIRFA_Filter | ( | iir_ctrl_t *const | p_api_ctrl, |
float const * | p_data_in, | ||
float * | p_data_out, | ||
uint16_t const | num_samples | ||
) |
Start a filter operation on the specified data.
FSP_SUCCESS | Data has been successfully filtered. |
FSP_ERR_ASSERTION | One of the provided pointers is NULL. |
FSP_ERR_NOT_OPEN | Instance is not open. |
FSP_ERR_INVALID_ARGUMENT | num_samples is zero. |
FSP_ERR_INVALID_RESULT | The result of one or more calculations was +/- infinity. |
FSP_ERR_NOT_INITIALIZED | The filter is not configured. |
FSP_ERR_IIRFA_ECC_1BIT | A 1-bit ECC error was detected. |
FSP_ERR_IIRFA_ECC_2BIT | A 2-bit ECC error was detected. |
fsp_err_t R_IIRFA_Configure | ( | iir_ctrl_t *const | p_api_ctrl, |
iir_filter_cfg_t const *const | p_filter_cfg | ||
) |
Configure filter coefficients and state values.
FSP_SUCCESS | Configuration successful. |
FSP_ERR_ASSERTION | p_api_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Instance is not open. |
FSP_ERR_INVALID_ARGUMENT | Invalid filter stage selection. |
FSP_ERR_IN_USE | One or more requested filter stages are currently in use. |
fsp_err_t R_IIRFA_StatusGet | ( | iir_ctrl_t *const | p_api_ctrl, |
iir_status_t *const | p_status | ||
) |
Read the current filter state variables.
FSP_SUCCESS | Information read successfully. |
FSP_ERR_ASSERTION | p_api_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Instance is not open. |
fsp_err_t R_IIRFA_Close | ( | iir_ctrl_t *const | p_api_ctrl | ) |
Stop filter operations and close the channel instance.
FSP_SUCCESS | The channel is successfully closed. |
FSP_ERR_ASSERTION | p_api_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Instance is not open. |
__STATIC_INLINE float R_IIRFA_SingleFilter | ( | iir_ctrl_t *const | p_api_ctrl, |
float | data_in | ||
) |
Perform a single inline filter operation.