RZV Flexible Software Package Documentation
Release v3.0.0
|
|
Functions | |
fsp_err_t | R_PDM_Open (pdm_ctrl_t *const p_ctrl, pdm_cfg_t const *const p_cfg) |
fsp_err_t | R_PDM_Start (pdm_ctrl_t *const p_ctrl, void *const p_buffer, size_t const buffer_size, uint32_t const number_of_data_to_callback) |
fsp_err_t | R_PDM_Stop (pdm_ctrl_t *const p_ctrl) |
fsp_err_t | R_PDM_Read (pdm_ctrl_t *const p_ctrl, void *const p_dest, uint32_t const bytes) |
fsp_err_t | R_PDM_StatusGet (pdm_ctrl_t *const p_ctrl, pdm_status_t *const p_status) |
fsp_err_t | R_PDM_Close (pdm_ctrl_t *const p_ctrl) |
fsp_err_t | R_PDM_CallbackSet (pdm_ctrl_t *const p_ctrl, void(*p_callback)(pdm_callback_args_t *), void const *const p_context, pdm_callback_args_t *const p_callback_memory) |
Driver for the PDM peripheral on RZ MPUs. This module implements the PDM Interface.
The PDM module supports the following features:
Reception of a voice data from external PDM device
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
DMAC Support |
| Disabled | If code for DMAC transfer support is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Input > Edge |
| Rising | Select the edge of input audio data. |
Input > PDM_CLK frequency | Refer to the RZV Configuration tool for available options. | module.driver.pdm.clock_div.clock_div_2 | Select PDM_CLK Frequency (MHz). |
Output > Bit Depth |
| module.driver.pdm.pcm_width.pcm_width_20bits_0_18 | Select the bit depth of one sample of audio data. |
Output > Target sampling frequency | Refer to the RZV Configuration tool for available options. | 30 kHz | Select Target sampling Frequency (kHz). |
Filter > Low-pass filter > Low-pass filter input shift |
| No shift | Select the low-pass (half-band decimation) filter input shift setting. |
Filter > Low-pass filter > LPF Coefficient h0(10) | Value must be an integer between 0x0000 and 0x1FFF | 0x0400 | Specify the Low-Pass Filter Coefficient h0(10) |
Filter > Low-pass filter > LPF Coefficient h1(0) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FF8 | Specify the Low-Pass Filter Coefficient h1(0) |
Filter > Low-pass filter > LPF Coefficient h1(1) | Value must be an integer between 0x0000 and 0x1FFF | 0x000A | Specify the Low-Pass Filter Coefficient h1(1) |
Filter > Low-pass filter > LPF Coefficient h1(2) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FF0 | Specify the Low-Pass Filter Coefficient h1(2) |
Filter > Low-pass filter > LPF Coefficient h1(3) | Value must be an integer between 0x0000 and 0x1FFF | 0x0018 | Specify the Low-Pass Filter Coefficient h1(3) |
Filter > Low-pass filter > LPF Coefficient h1(4) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FDC | Specify the Low-Pass Filter Coefficient h1(4) |
Filter > Low-pass filter > LPF Coefficient h1(5) | Value must be an integer between 0x0000 and 0x1FFF | 0x0034 | Specify the Low-Pass Filter Coefficient h1(5) |
Filter > Low-pass filter > LPF Coefficient h1(6) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FB3 | Specify the Low-Pass Filter Coefficient h1(6) |
Filter > Low-pass filter > LPF Coefficient h1(7) | Value must be an integer between 0x0000 and 0x1FFF | 0x0076 | Specify the Low-Pass Filter Coefficient h1(7) |
Filter > Low-pass filter > LPF Coefficient h1(8) | Value must be an integer between 0x0000 and 0x1FFF | 0x1F2E | Specify the Low-Pass Filter Coefficient h1(8) |
Filter > Low-pass filter > LPF Coefficient h1(9) | Value must be an integer between 0x0000 and 0x1FFF | 0x0289 | Specify the Low-Pass Filter Coefficient h1(9) |
Filter > Low-pass filter > LPF Coefficient h1(10) | Value must be an integer between 0x0000 and 0x1FFF | 0x0289 | Specify the Low-Pass Filter Coefficient h1(10) |
Filter > Low-pass filter > LPF Coefficient h1(11) | Value must be an integer between 0x0000 and 0x1FFF | 0x1F2E | Specify the Low-Pass Filter Coefficient h1(11) |
Filter > Low-pass filter > LPF Coefficient h1(12) | Value must be an integer between 0x0000 and 0x1FFF | 0x0076 | Specify the Low-Pass Filter Coefficient h1(12) |
Filter > Low-pass filter > LPF Coefficient h1(13) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FB3 | Specify the Low-Pass Filter Coefficient h1(13) |
Filter > Low-pass filter > LPF Coefficient h1(14) | Value must be an integer between 0x0000 and 0x1FFF | 0x0034 | Specify the Low-Pass Filter Coefficient h1(14) |
Filter > Low-pass filter > LPF Coefficient h1(15) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FDC | Specify the Low-Pass Filter Coefficient h1(15) |
Filter > Low-pass filter > LPF Coefficient h1(16) | Value must be an integer between 0x0000 and 0x1FFF | 0x0018 | Specify the Low-Pass Filter Coefficient h1(16) |
Filter > Low-pass filter > LPF Coefficient h1(17) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FF0 | Specify the Low-Pass Filter Coefficient h1(17) |
Filter > Low-pass filter > LPF Coefficient h1(18) | Value must be an integer between 0x0000 and 0x1FFF | 0x000A | Specify the Low-Pass Filter Coefficient h1(18) |
Filter > Low-pass filter > LPF Coefficient h1(19) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FF8 | Specify the Low-Pass Filter Coefficient h1(19) |
Filter > Compensation filter > Compensation filter input shift |
| No shift | Select the compensation filter input shift setting. |
Filter > Compensation filter > Compensation Filter Coefficient h(0) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FE8 | Specify the Compensation Filter Coefficient h(0) |
Filter > Compensation filter > Compensation Filter Coefficient h(1) | Value must be an integer between 0x0000 and 0x1FFF | 0x0039 | Specify the Compensation Filter Coefficient h(1) |
Filter > Compensation filter > Compensation Filter Coefficient h(2) | Value must be an integer between 0x0000 and 0x1FFF | 0x003C | Specify the Compensation Filter Coefficient h(2) |
Filter > Compensation filter > Compensation Filter Coefficient h(3) | Value must be an integer between 0x0000 and 0x1FFF | 0x1E56 | Specify the Compensation Filter Coefficient h(3) |
Filter > Compensation filter > Compensation Filter Coefficient h(4) | Value must be an integer between 0x0000 and 0x1FFF | 0x01DC | Specify the Compensation Filter Coefficient h(4) |
Filter > Compensation filter > Compensation Filter Coefficient h(5) | Value must be an integer between 0x0000 and 0x1FFF | 0x06E1 | Specify the Compensation Filter Coefficient h(5) |
Filter > Compensation filter > Compensation Filter Coefficient h(6) | Value must be an integer between 0x0000 and 0x1FFF | 0x01DC | Specify the Compensation Filter Coefficient h(6) |
Filter > Compensation filter > Compensation Filter Coefficient h(7) | Value must be an integer between 0x0000 and 0x1FFF | 0x1E56 | Specify the Compensation Filter Coefficient h(7) |
Filter > Compensation filter > Compensation Filter Coefficient h(8) | Value must be an integer between 0x0000 and 0x1FFF | 0x003C | Specify the Compensation Filter Coefficient h(8) |
Filter > Compensation filter > Compensation Filter Coefficient h(9) | Value must be an integer between 0x0000 and 0x1FFF | 0x0039 | Specify the Compensation Filter Coefficient h(9) |
Filter > Compensation filter > Compensation Filter Coefficient h(10) | Value must be an integer between 0x0000 and 0x1FFF | 0x1FE8 | Specify the Compensation Filter Coefficient h(10) |
Filter > High-pass filter > High-pass filter input shift |
| No shift | Select the high-pass filter input shift setting. |
Filter > High-pass filter > HPF Coefficient s(0) | Value must be an integer between 0x0000 and 0xFFFF | 0x3F61 | Specify the High-Pass Filter Coefficient s(0) |
Filter > High-pass filter > HPF Coefficient k(1) | Value must be an integer between 0x0000 and 0xFFFF | 0x3EC1 | Specify the High-Pass Filter Coefficient k(1) |
Filter > High-pass filter > HPF Coefficient h(0) | Value must be an integer between 0x0000 and 0xFFFF | 0x4000 | Specify the High-Pass Filter Coefficient h(0) |
Filter > High-pass filter > HPF Coefficient h(1) | Value must be an integer between 0x0000 and 0xFFFF | 0xC000 | Specify the High-Pass Filter Coefficient h(1) |
Filter > Moving average mode |
| 1-order (filter is skipped) | Select the moving average mode for sound detection data. |
Filter > Sinc filter mode |
| 4-order | Select the sinc filter mode setting. |
Data Reception > Buffer overwrite detection enable |
| Enabled | Select buffer overwrite detection. |
Data Reception > Data reception interrupt threshold |
| 1 or more data | Select Data reception interrupt threshold. |
Sound Detection > Sound detection enable |
| module.driver.pdm.sound_detection.sound_detection | Select sound detection. |
Sound Detection > Sound detection lower limit | Value must be an integer between 0x0000 and 0xFFFFF | 0x0 | Specify the Sound detection lower limit |
Sound Detection > Sound detection upper limit | Value must be an integer between 0x0000 and 0xFFFFF | 0x0 | Specify the Sound detection upper limit |
Short circuit detection > Short circuit detection enable |
| module.driver.pdm.short_circuit.short_circuit | Select short circuit detection. |
Short circuit detection > Short circuit detection High Continuous detection count | Value must be an integer between 0x0000 and 0x1FFF | 0x0 | Specify the Short circuit detection High Continuous detection count. |
Short circuit detection > Short circuit detection Low Continuous detection count | Value must be an integer between 0x0000 and 0x1FFF | 0x0 | Short circuit detection Low Continuous detection count. |
Overvoltage detection > Overvoltage detection lower limit enable |
| module.driver.pdm.overvoltage_detection_lower_limit_error.overvoltage_detection_lower_limit_error | Select overvoltage detection lower limit. |
Overvoltage detection > Overvoltage detection lower limit | Value must be an integer between 0x0000 and 0xFFFFF | 0x0 | Specify the Overvoltage detection lower limit |
Overvoltage detection > Overvoltage detection upper limit enable |
| module.driver.pdm.overvoltage_detection_upper_limit_error.overvoltage_detection_upper_limit_error | Select overvoltage detection upper limit. |
Overvoltage detection > Overvoltage detection upper limit | Value must be an integer between 0x0000 and 0xFFFFF | 0x0 | Specify the Overvoltage detection upper limit |
Interrupt > Callback | Name must be a valid C symbol | NULL | A user callback function can be provided. If this callback function is provided, it will be called from all three interrupt service routines (ISR). |
Interrupt > Sound Detection Interrupt Enable | MCU Specific Options | Enable the sound detection interrupt. | |
Interrupt > Sound Detection Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the sound detection interrupt priority. |
Interrupt > Data Reception Interrupt Enable | MCU Specific Options | Enable the data reception interrupt. | |
Interrupt > Data Reception Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the data reception interrupt priority. |
Interrupt > Error Detection Interrupt Enable | MCU Specific Options | Enable the error detection interrupt. | |
Interrupt > Error Detection Interrupt Priority | Value must be an integer between 0 and 255 | 24 | Select the error detection interrupt priority. |
Name | Name must be a valid C symbol | g_pdm0 | Module name. |
Unit | Value must be an non-negative integer | 0 | Specify the PDM unit. |
Channel | Value must be an non-negative integer | 1 | Specify the PDM channel. |
This module has no required clock configurations.
The PDM uses the following pins:
PDM hardware converts PDM data to PCM data.
Data arrays have the following size, alignment, and length based on the "Bit Depth" setting:
Bit Depth | Array Data Type | Required Alignment |
---|---|---|
16 Bits | 32-bit integer, right justified | 4 byte alignment |
20 Bits | 32-bit integer, right justified | 4 byte alignment |
Bit | Description |
---|---|
31-20 | Fixed to 0 |
19-16 | Sign bits |
15-0 | Fixed-point data |
Bit | Description |
---|---|
31-20 | Fixed to 0 |
19-0 | Fixed-point data |
This is a basic example of minimal use of the PDM in an application.
Data Structures | |
struct | pdm_instance_ctrl_t |
struct | pdm_extended_cfg_t |
Enumerations | |
enum | pdm_clk_div_t |
enum | pdm_moving_average_mode_t |
enum | pdm_low_pass_filter_shift_t |
enum | pdm_compensation_filter_shift_t |
enum | pdm_high_pass_filter_shift_t |
enum | pdm_sinc_filter_mode_t |
enum | pdm_interrupt_threshold_t |
struct pdm_instance_ctrl_t |
Channel instance control block. DO NOT INITIALIZE. Initialization occurs when pdm_api_t::open is called.
struct pdm_extended_cfg_t |
PDM configuration extension. This extension is optional.
Data Fields | ||
---|---|---|
pdm_clk_div_t | clock_div | PDM_CLKn's division ratio to core clock. |
uint8_t | sound_detection_enable |
Sound detection enable. Function Settings. |
uint8_t | short_circuit_detection_enable | Short circuit detection enable. |
uint8_t | over_voltage_lower_limit_detection_enable | Overvoltage detection lower limit enable. |
uint8_t | over_voltage_upper_limit_detection_enable | Overvoltage detection upper limit enable. |
uint8_t | buffer_overwrite_detection_enable | Buffer overwrite detection enable. |
pdm_moving_average_mode_t | moving_average_mode |
Moving average mode f or sound detection data. Filter Settings. |
pdm_low_pass_filter_shift_t | low_pass_filter_shift | Low-pass (half -band decimation) filter input shift setting. |
pdm_compensation_filter_shift_t | compensation_filter_shift | Compensation filter input shift setting. |
pdm_high_pass_filter_shift_t | high_pass_filter_shift | High-pass filter input shift setting. |
pdm_sinc_filter_mode_t | sinc_filter_mode | Sinc filter mode setting. |
uint8_t | sincrng | Sinc filter output valid range. |
uint8_t | sincdec | Sinc filter decimation ratio. |
uint16_t | hpf_coefficient_s0 | High-pass filter coefficient s0 (16-bit signed fixed point data) |
uint16_t | hpf_coefficient_k1 | High-pass filter coefficient k1 (16-bit signed fixed point data) |
uint16_t | hpf_coefficient_h[2] | High-pass filter coefficient h(p) (16-bit signed fixed point data) |
uint16_t | compensation_filter_coefficient_h[11] | High-pass filter coefficient h(p) (13-bit signed fixed point data) |
uint16_t | lpf_coefficient_h0 | Low-pass (half-band decimation) filter coefficient h0 (13-bit signed fixed point data) |
uint16_t | lpf_coefficient_h1[20] | Low-pass (half-band decimation) filter coefficient h1 (13-bit signed fixed point data) |
uint32_t | filter_setting_time | Filter setting time. |
pdm_interrupt_threshold_t | interupt_threshold |
Data reception interrupt threshold. Sound Detection Threshold. |
uint32_t | sound_detection_lower_limit | Sound detection lower limit (20-bit signed fixed point data) |
uint32_t | sound_detection_upper_limit | Sound detection upper limit (20-bit signed fixed point data) |
uint16_t | short_circuit_count_h |
Short circuit detection High Continuous detection count. Short-Circuit Detection. |
uint16_t | short_circuit_count_l | Continuous detection count. |
uint32_t | overvoltage_detection_lower_limit |
Overvoltage detection lower limit (20-bit signed fixed point data) Overvoltage Detection. |
uint32_t | overvoltage_detection_upper_limit | Overvoltage detection upper limit (20-bit signed fixed point data) |
enum pdm_clk_div_t |
PDM_CLKn's division ratio to core clock.
Data reception interrupt threshold.
fsp_err_t R_PDM_Open | ( | pdm_ctrl_t *const | p_ctrl, |
pdm_cfg_t const *const | p_cfg | ||
) |
Opens the PDM. Implements pdm_api_t::open.
This function sets this clock divisor and the configurations specified in pdm_cfg_t. It also opens the timer and transfer instances if they are provided.
FSP_SUCCESS | Ready for PDM communication. |
FSP_ERR_ASSERTION | The pointer to p_ctrl or p_cfg is null. |
FSP_ERR_ALREADY_OPEN | The control block has already been opened. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | Channel number is not available on this device. |
fsp_err_t R_PDM_Start | ( | pdm_ctrl_t *const | p_ctrl, |
void *const | p_buffer, | ||
size_t const | buffer_size, | ||
uint32_t const | number_of_data_to_callback | ||
) |
Starts PDM. Implements pdm_api_t::start.
This function enables reception, and enables any transfer instances used.
The PDM will start on the next frame boundary.
FSP_SUCCESS | PDM communication stop request issued. |
FSP_ERR_ASSERTION | The pointer to p_ctrl was null. |
FSP_ERR_INVALID_SIZE | The size of buffer is not the multiple of pdm_interrupt_threshold_t. |
FSP_ERR_INVALID_ALIGNMENT | The alignment of argument buffer_size is not matched with hardware specification. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
fsp_err_t R_PDM_Stop | ( | pdm_ctrl_t *const | p_ctrl | ) |
Stops PDM. Implements pdm_api_t::stop.
This function disables reception, and disables any transfer instances used.
The PDM will stop on the next frame boundary.
FSP_SUCCESS | PDM communication stop request issued. |
FSP_ERR_ASSERTION | The pointer to p_ctrl was null. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
fsp_err_t R_PDM_Read | ( | pdm_ctrl_t *const | p_ctrl, |
void *const | p_dest, | ||
uint32_t const | bytes | ||
) |
Reads data into provided buffer. Implements pdm_api_t::read.
This function resets the transfer if the transfer interface is used, or reads the length of data available in the FIFO then stores the remaining read buffer in the control block to be filled in the ISR.
Read() cannot be called if another Start() operation is in progress. Read can be called when the PDM is idle.
FSP_SUCCESS | Read initiated successfully. |
FSP_ERR_IN_USE | Peripheral is in the wrong mode or not idle. |
FSP_ERR_ASSERTION | The pointer to p_ctrl or p_dest was null, or bytes requested was 0. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
fsp_err_t R_PDM_StatusGet | ( | pdm_ctrl_t *const | p_ctrl, |
pdm_status_t *const | p_status | ||
) |
Gets PDM status and stores it in provided pointer p_status. Implements pdm_api_t::statusGet.
FSP_SUCCESS | Information stored successfully. |
FSP_ERR_ASSERTION | The p_ctrl or p_status parameter was null. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
fsp_err_t R_PDM_Close | ( | pdm_ctrl_t *const | p_ctrl | ) |
Closes PDM. Implements pdm_api_t::close.
This function powers down the PDM and closes the lower level timer and transfer drivers if they are used.
FSP_SUCCESS | Device closed successfully. |
FSP_ERR_ASSERTION | The pointer to p_ctrl was null. |
FSP_ERR_NOT_OPEN | The channel is not opened. |
fsp_err_t R_PDM_CallbackSet | ( | pdm_ctrl_t *const | p_ctrl, |
void(*)(pdm_callback_args_t *) | p_callback, | ||
void const *const | p_context, | ||
pdm_callback_args_t *const | p_callback_memory | ||
) |
Updates the user callback and has option of providing memory for callback structure. Implements pdm_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_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |