RA Flexible Software Package Documentation  Release v6.0.0

 
Pulse Density Modulation Interface (r_pdm)

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_SoundDetectionEnable (pdm_ctrl_t *const p_ctrl, pdm_sound_detection_setting_t sound_detection_setting)
 
fsp_err_t R_PDM_SoundDetectionDisable (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 p_context, pdm_callback_args_t *const p_callback_memory)
 

Detailed Description

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

Overview

The Pulse Density Modulation Interface (PDM-IF) has channels that are connectable with external microphone which outputs the pulse density modulated signal. PDM-IF can filter and convert 1-bit digital data streams that were pulse density modulated at a high sampling rate into 20-bit or 16-bit digital data at a lower sampling rate.

Features

Configuration

Build Time Configurations for r_pdm

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

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
DMAC Support
  • Enabled
  • Disabled
Disabled If enabled code for DMAC transfer support is included in the build.

Configurations for Audio > PDM (r_pdm)

This module can be added to the Stacks tab via New Stack > Audio > PDM (r_pdm).

ConfigurationOptionsDefaultDescription
Input
Edge
  • Rising
  • Falling
Rising Select the edge of input audio data.
PDM_CLK FrequencyRefer to the RA Configuration tool for available options.module.driver.pdm.clock_div.clock_div_2 Select PDM_CLK Frequency (Hz).
Output
Bit Format
  • 20 Bits mode {1 Sign bit and [18:0] bits of the buffer}
  • 20 Bits mode {2 Sign bits and [18:1] bits of the buffer}
  • 20 Bits mode {3 Sign bits and [18:2] bits of the buffer}
  • 20 Bits mode {4 Sign bits and [18:3] bits of the buffer}
  • 16 Bits mode {1 Sign bit and [18:4] bits of the buffer}
  • 16 Bits mode {1 Sign bit and [17:3] bits of the buffer}
  • 16 Bits mode {1 Sign bit and [16:2] bits of the buffer}
  • 16 Bits mode {1 Sign bit and [15:1] bits of the buffer}
  • 16 Bits mode {1 Sign bit and [14:0] bits of the buffer}
module.driver.pdm.pcm_width.pcm_width_20bits_0_18 Select the bit format of the PCM data stored into the data FIFO.
Target Sampling Frequency (Hz)Manual Entry32000 Select Target sampling Frequency (Hz).
Filter
Filter > Low-pass Filter
Low-pass Filter Input Shift
  • No shift
  • 1-bit right shift
  • 2-bits right shift
  • 3-bits right shift
No shift Select the low-pass (half-band decimation) filter input shift setting.
LPF Coefficient h0(10)Value must be an integer between 0x0000 and 0x1FFF0x0400 Specify the Low-Pass Filter Coefficient h0(10)
LPF Coefficient h1(0)Value must be an integer between 0x0000 and 0x1FFF0x1FF8 Specify the Low-Pass Filter Coefficient h1(0)
LPF Coefficient h1(1)Value must be an integer between 0x0000 and 0x1FFF0x000A Specify the Low-Pass Filter Coefficient h1(1)
LPF Coefficient h1(2)Value must be an integer between 0x0000 and 0x1FFF0x1FF0 Specify the Low-Pass Filter Coefficient h1(2)
LPF Coefficient h1(3)Value must be an integer between 0x0000 and 0x1FFF0x0018 Specify the Low-Pass Filter Coefficient h1(3)
LPF Coefficient h1(4)Value must be an integer between 0x0000 and 0x1FFF0x1FDC Specify the Low-Pass Filter Coefficient h1(4)
LPF Coefficient h1(5)Value must be an integer between 0x0000 and 0x1FFF0x0034 Specify the Low-Pass Filter Coefficient h1(5)
LPF Coefficient h1(6)Value must be an integer between 0x0000 and 0x1FFF0x1FB3 Specify the Low-Pass Filter Coefficient h1(6)
LPF Coefficient h1(7)Value must be an integer between 0x0000 and 0x1FFF0x0076 Specify the Low-Pass Filter Coefficient h1(7)
LPF Coefficient h1(8)Value must be an integer between 0x0000 and 0x1FFF0x1F2E Specify the Low-Pass Filter Coefficient h1(8)
LPF Coefficient h1(9)Value must be an integer between 0x0000 and 0x1FFF0x0289 Specify the Low-Pass Filter Coefficient h1(9)
LPF Coefficient h1(10)Value must be an integer between 0x0000 and 0x1FFF0x0289 Specify the Low-Pass Filter Coefficient h1(10)
LPF Coefficient h1(11)Value must be an integer between 0x0000 and 0x1FFF0x1F2E Specify the Low-Pass Filter Coefficient h1(11)
LPF Coefficient h1(12)Value must be an integer between 0x0000 and 0x1FFF0x0076 Specify the Low-Pass Filter Coefficient h1(12)
LPF Coefficient h1(13)Value must be an integer between 0x0000 and 0x1FFF0x1FB3 Specify the Low-Pass Filter Coefficient h1(13)
LPF Coefficient h1(14)Value must be an integer between 0x0000 and 0x1FFF0x0034 Specify the Low-Pass Filter Coefficient h1(14)
LPF Coefficient h1(15)Value must be an integer between 0x0000 and 0x1FFF0x1FDC Specify the Low-Pass Filter Coefficient h1(15)
LPF Coefficient h1(16)Value must be an integer between 0x0000 and 0x1FFF0x0018 Specify the Low-Pass Filter Coefficient h1(16)
LPF Coefficient h1(17)Value must be an integer between 0x0000 and 0x1FFF0x1FF0 Specify the Low-Pass Filter Coefficient h1(17)
LPF Coefficient h1(18)Value must be an integer between 0x0000 and 0x1FFF0x000A Specify the Low-Pass Filter Coefficient h1(18)
LPF Coefficient h1(19)Value must be an integer between 0x0000 and 0x1FFF0x1FF8 Specify the Low-Pass Filter Coefficient h1(19)
Filter > Compensation Filter
Compensation Filter Input Shift
  • No shift
  • 1-bit right shift
  • 2-bits right shift
  • 3-bits right shift
No shift Select the compensation filter input shift setting.
Compensation Filter Coefficient h(0)Value must be an integer between 0x0000 and 0x1FFF0x1FE8 Specify the Compensation Filter Coefficient h(0)
Compensation Filter Coefficient h(1)Value must be an integer between 0x0000 and 0x1FFF0x0039 Specify the Compensation Filter Coefficient h(1)
Compensation Filter Coefficient h(2)Value must be an integer between 0x0000 and 0x1FFF0x003C Specify the Compensation Filter Coefficient h(2)
Compensation Filter Coefficient h(3)Value must be an integer between 0x0000 and 0x1FFF0x1E56 Specify the Compensation Filter Coefficient h(3)
Compensation Filter Coefficient h(4)Value must be an integer between 0x0000 and 0x1FFF0x01DC Specify the Compensation Filter Coefficient h(4)
Compensation Filter Coefficient h(5)Value must be an integer between 0x0000 and 0x1FFF0x06E1 Specify the Compensation Filter Coefficient h(5)
Compensation Filter Coefficient h(6)Value must be an integer between 0x0000 and 0x1FFF0x01DC Specify the Compensation Filter Coefficient h(6)
Compensation Filter Coefficient h(7)Value must be an integer between 0x0000 and 0x1FFF0x1E56 Specify the Compensation Filter Coefficient h(7)
Compensation Filter Coefficient h(8)Value must be an integer between 0x0000 and 0x1FFF0x003C Specify the Compensation Filter Coefficient h(8)
Compensation Filter Coefficient h(9)Value must be an integer between 0x0000 and 0x1FFF0x0039 Specify the Compensation Filter Coefficient h(9)
Compensation Filter Coefficient h(10)Value must be an integer between 0x0000 and 0x1FFF0x1FE8 Specify the Compensation Filter Coefficient h(10)
Filter > High-pass Filter
High-pass Filter Input Shift
  • No shift
  • 1-bit right shift
  • 2-bits right shift
  • 3-bits right shift
No shift Select the high-pass filter input shift setting.
HPF Coefficient s(0)Value must be an integer between 0x0000 and 0xFFFF0x3F61 Specify the High-Pass Filter Coefficient s(0)
HPF Coefficient k(1)Value must be an integer between 0x0000 and 0xFFFF0x3EC1 Specify the High-Pass Filter Coefficient k(1)
HPF Coefficient h(0)Value must be an integer between 0x0000 and 0xFFFF0x4000 Specify the High-Pass Filter Coefficient h(0)
HPF Coefficient h(1)Value must be an integer between 0x0000 and 0xFFFF0xC000 Specify the High-Pass Filter Coefficient h(1)
Moving Average Mode
  • 1-order (filter is skipped)
  • 2-order
  • 4-order
1-order (filter is skipped) Select the moving average mode for sound detection data.
Sinc Filter Mode
  • 1-order
  • 2-order
  • 3-order
  • 4-order
4-order Select the sinc filter mode setting.
Data Reception
Buffer Overwrite Detection Enable
  • Enabled
  • Disabled
Enabled Select buffer overwrite detection.
Data Reception Interrupt Threshold
  • 1 or more data
  • 2 or more data
  • 4 or more data
  • 8 or more data
  • 16 or more data
16 or more data Select Data reception interrupt threshold.
Short Circuit Detection
Short Circuit Detection Enable
  • Enabled
  • Disabled
Disabled Select short circuit detection.
Short Circuit Detection High Continuous Detection CountValue must be an integer between 0x0000 and 0x1FFF0x0 Specify the Short circuit detection High Continuous detection count.
Short Circuit Detection Low Continuous Detection CountValue must be an integer between 0x0000 and 0x1FFF0x0 Short circuit detection Low Continuous detection count.
Overvoltage Detection
Overvoltage Detection Lower Limit Enable
  • Enabled
  • Disabled
Disabled Select overvoltage detection lower limit.
Overvoltage Detection Lower LimitValue must be an integer between 0x0000 and 0xFFFFF0x0 Specify the Overvoltage detection lower limit
Overvoltage Detection Upper Limit Enable
  • Enabled
  • Disabled
Disabled Select overvoltage detection upper limit.
Overvoltage Detection Upper LimitValue must be an integer between 0x0000 and 0xFFFFF0x0 Specify the Overvoltage detection upper limit
Interrupt
CallbackName must be a valid C symbolNULL A user callback function can be provided. If this callback function is provided, it will be called from all three interrupt service routines (ISR).
Sound Detection Interrupt PriorityMCU Specific OptionsSelect the sound detection interrupt priority.
Data Reception Interrupt PriorityMCU Specific OptionsSelect the data reception interrupt priority.
Error Detection Interrupt PriorityMCU Specific OptionsSelect the error detection interrupt priority.
NameName must be a valid C symbolg_pdm0 Module name.
ChannelValue must be an non-negative integer0 Specify the PDM channel.

Usage Notes

Startup and Settling Time

Upon calling R_PDM_Open the user must wait for the filters to settle and any connected microphones to startup, otherwise PDM data may not be correct upon calling R_PDM_Start.

A macro G_PDMn_FILTER_SETTLING_TIME_US (where n is the channel number) is generated for the settling time. The user can use this macro to delay for the settling time via their preferred method of doing a delay.

In addition to the filter settling time any connected microphone startup time should be accounted for. This can be found in the connected microphone's datasheet.

Audio Data

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

Data Format for 16 Bits

Bit Description
31-20 Fixed to 0
19-16 Sign bits
15-0 Fixed-point data

Data Format for 20 Bits

Bit Description
31-20 Fixed to 0
19-0 Fixed-point data

Modes of Operation

In addition to calling R_PDM_Open, other APIs need to be called to activate certain features of PDM. The following table lists what each API controls:

API Features Enabled by API
R_PDM_Open over/undervoltage detection, short circuit detection
R_PDM_Start data reception via interrupts or DMAC depending configuration, error interrupts
R_PDM_SoundDetectionEnable sound detection, sound detection thresholds, error interrupts

Error Interrupts

Error interrupts are only enabled when data reception is enabled (R_PDM_Start has been called) OR sound detection is enabled (R_PDM_SoundDetectionEnable has been called).

R_PDM_StatusGet can be called to get error statuses if error interrupts are not enabled (e.g. if only R_PDM_Open has been called).

Low Power Mode

Note
In order to use PDM during low power mode MOCO must be enabled for software standby mode (see MOCOSCR register).

Some microphones support going into a low power mode by changing the PDM clock to a low frequency. In order to do this with r_pdm the module instance should be closed and reopened with a separate configuration that uses a lower PDM clock.

Limitations

Examples

Basic Example

#define PDM_BUFFER_NUM_SAMPLES 1024 // Number of samples to store in data buffer
#define PDM_CALLBACK_NUM_SAMPLES PDM_BUFFER_NUM_SAMPLES / 2 // Number of samples to store in data buffer before getting a callback
#define PDM_MIC_STARTUP_TIME_US 35000 // PDM microphone startup time, RA8P1_EK mic startup time is 35ms
#define PDM_SDE_UPPER_LIMIT 5000 // Detect sound above this value
#define PDM_SDE_LOWER_LIMIT 0xFFF80000 // Detect sound below this value
uint32_t g_pdm0_buffer[PDM_BUFFER_NUM_SAMPLES];
void r_pdm_basic_messaging_core0_example (void)
{
/* Open PDM instance. */
fsp_err_t err = R_PDM_Open(&g_pdm0_ctrl, &g_pdm0_cfg);
assert(FSP_SUCCESS == err);
/* Wait for PDM filters to settle. Use settling time calculated by e2 studio.
* Also wait for PDM mic to startup. */
R_BSP_SoftwareDelay(G_PDM0_FILTER_SETTLING_TIME_US + PDM_MIC_STARTUP_TIME_US, BSP_DELAY_UNITS_MICROSECONDS);
/* Enable sound detection (if desired). */
pdm_sound_detection_setting_t sound_detection_setting =
{
.sound_detection_lower_limit = PDM_SDE_LOWER_LIMIT,
.sound_detection_upper_limit = PDM_SDE_UPPER_LIMIT
};
fsp_err_t err = R_PDM_SoundDetectionEnable(&g_pdm0_ctrl, sound_detection_setting);
assert(FSP_SUCCESS == err);
/* Start receiving PDM data. */
err = R_PDM_Start(&g_pdm0_ctrl, g_pdm0_buffer, sizeof(g_pdm0_buffer), PDM_CALLBACK_NUM_SAMPLES);
assert(FSP_SUCCESS == err);
/* DATA PROCESSING HERE */
/* Stop receiving PDM data. */
err = R_PDM_Stop(&g_pdm0_ctrl);
assert(FSP_SUCCESS == err);
/* Close PDM instance. */
err = R_PDM_Close(&g_pdm0_ctrl);
assert(FSP_SUCCESS == err);
}
void pdm_example_callback (pdm_callback_args_t * p_args)
{
switch (p_args->event)
{
{
/* Sound has been detected based on configured thresholds. */
break;
}
{
/* PDM_CALLBACK_NUM_SAMPLES has been stored in g_pdm0_buffer. */
break;
}
{
{
/* Short circuit has been detected based on configured counts */
}
{
/* Overvoltage has been detected based on configured lower limit */
}
{
/* Overvoltage has been detected based on configured upper limit */
}
{
/* Buffer overwrite has occurred */
}
break;
}
default:
{
break;
}
}
}

Data Structures

struct  pdm_instance_ctrl_t
 
struct  pdm_extended_cfg_t
 

Macros

#define PDM_NUM_HPF_COEFFICIENT_H
 Number of high pass filter h coefficients.
 
#define PDM_NUM_COMPENSATION_FILTER_COEFFICIENT_H
 Number of compensation filter h coefficients.
 
#define PDM_NUM_LPF_FILTER_COEFFICIENT_H1
 Number of low pass filter h1 coefficients.
 

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
 
enum  pdm_short_circuit_enable_t
 
enum  pdm_overvoltage_lower_limit_enable_t
 
enum  pdm_overvoltage_upper_limit_enable_t
 
enum  pdm_buffer_overwrite_detection_enable_t
 

Data Structure Documentation

◆ pdm_instance_ctrl_t

struct pdm_instance_ctrl_t

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

◆ pdm_extended_cfg_t

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.
pdm_short_circuit_enable_t short_circuit_detection_enable Short circuit detection enable.

Function Settings.

pdm_overvoltage_lower_limit_enable_t over_voltage_lower_limit_detection_enable Overvoltage detection lower limit enable.
pdm_overvoltage_upper_limit_enable_t over_voltage_upper_limit_detection_enable Overvoltage detection upper limit enable.
pdm_buffer_overwrite_detection_enable_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[PDM_NUM_HPF_COEFFICIENT_H] High-pass filter coefficient h(p) (16-bit signed fixed point data)
uint16_t compensation_filter_coefficient_h[PDM_NUM_COMPENSATION_FILTER_COEFFICIENT_H] 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[PDM_NUM_LPF_FILTER_COEFFICIENT_H1] Low-pass (half-band decimation) filter coefficient h1 (13-bit signed fixed point data)
pdm_interrupt_threshold_t interrupt_threshold Data reception interrupt threshold.

Data Reception.

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)

Enumeration Type Documentation

◆ pdm_clk_div_t

PDM_CLKn's division ratio to core clock.

Enumerator
PDM_CLOCK_DIV_2 

0000b: 1/2

PDM_CLOCK_DIV_4 

0001b: 1/4

PDM_CLOCK_DIV_6 

0010b: 1/6

PDM_CLOCK_DIV_8 

0011b: 1/8

PDM_CLOCK_DIV_10 

0100b: 1/10

PDM_CLOCK_DIV_12 

0101b: 1/12

PDM_CLOCK_DIV_14 

0110b: 1/14

PDM_CLOCK_DIV_16 

0111b: 1/16

PDM_CLOCK_DIV_18 

1000b: 1/18

PDM_CLOCK_DIV_20 

1001b: 1/20

PDM_CLOCK_DIV_22 

1010b: 1/22

PDM_CLOCK_DIV_24 

1011b: 1/24

PDM_CLOCK_DIV_26 

1100b: 1/26

PDM_CLOCK_DIV_28 

1101b: 1/28

PDM_CLOCK_DIV_30 

1110b: 1/30

PDM_CLOCK_DIV_32 

1111b: 1/32

◆ pdm_moving_average_mode_t

Moving average mode for sound detection data.

Enumerator
PDM_MOVING_AVERAGE_MODE_1_ORDER 

1-order

PDM_MOVING_AVERAGE_MODE_2_ORDER 

2-order

PDM_MOVING_AVERAGE_MODE_4_ORDER 

4-order

◆ pdm_low_pass_filter_shift_t

Low-pass (half-band decimation) filter input shift setting.

Enumerator
PDM_LPF_RIGHT_SHIFT_0 

No shift.

PDM_LPF_RIGHT_SHIFT_1 

1-bit right shift

PDM_LPF_RIGHT_SHIFT_2 

2-bit right shift

PDM_LPF_RIGHT_SHIFT_3 

3-bit right shift

◆ pdm_compensation_filter_shift_t

Compensation filter input shift setting.

Enumerator
PDM_COMPENSATION_FILTER_RIGHT_SHIFT_0 

No shift.

PDM_COMPENSATION_FILTER_RIGHT_SHIFT_1 

1-bit right shift

PDM_COMPENSATION_FILTER_RIGHT_SHIFT_2 

2-bit right shift

PDM_COMPENSATION_FILTER_RIGHT_SHIFT_3 

3-bit right shift

◆ pdm_high_pass_filter_shift_t

High-pass filter input shift setting.

Enumerator
PDM_HPF_RIGHT_SHIFT_0 

No shift.

PDM_HPF_RIGHT_SHIFT_1 

1-bit right shift

PDM_HPF_RIGHT_SHIFT_2 

2-bit right shift

PDM_HPF_RIGHT_SHIFT_3 

3-bit right shift

◆ pdm_sinc_filter_mode_t

Sinc filter mode setting.

Enumerator
PDM_SINC_FILTER_MODE_1 

1-order

PDM_SINC_FILTER_MODE_2 

2-order

PDM_SINC_FILTER_MODE_3 

3-order

PDM_SINC_FILTER_MODE_4 

4-order

◆ pdm_interrupt_threshold_t

Data reception interrupt threshold.

Enumerator
PDM_INTERRUPT_THRESHOLD_1 

000b: Output interrupt when receiving 1 or more data

PDM_INTERRUPT_THRESHOLD_2 

001b: Output interrupt when receiving 2 or more data

PDM_INTERRUPT_THRESHOLD_4 

010b: Output interrupt when receiving 4 or more data

PDM_INTERRUPT_THRESHOLD_8 

011b: Output interrupt when receiving 8 or more data

PDM_INTERRUPT_THRESHOLD_16 

100b: Output interrupt when receiving 16 or more data

◆ pdm_short_circuit_enable_t

Short circuit detection enable setting.

Enumerator
PDM_SHORT_CIRCUIT_DISABLED 

Short circuit disabled.

PDM_SHORT_CIRCUIT_ENABLED 

Short circuit enabled.

◆ pdm_overvoltage_lower_limit_enable_t

Overvoltage lower limit enable setting.

Enumerator
PDM_OVERVOLTAGE_LOWER_LIMIT_DISABLED 

Overvoltage lower limit disabled.

PDM_OVERVOLTAGE_LOWER_LIMIT_ENABLED 

Overvoltage lower limit enabled.

◆ pdm_overvoltage_upper_limit_enable_t

Overvoltage upper limit enable setting.

Enumerator
PDM_OVERVOLTAGE_UPPER_LIMIT_DISABLED 

Overvoltage upper limit disabled.

PDM_OVERVOLTAGE_UPPER_LIMIT_ENABLED 

Overvoltage upper limit enabled.

◆ pdm_buffer_overwrite_detection_enable_t

Buffer overwrite detection enable setting.

Enumerator
PDM_BUFFER_OVERWRITE_DETECTION_DISABLED 

Buffer overwrite detection disabled.

PDM_BUFFER_OVERWRITE_DETECTION_ENABLED 

Buffer overwrite detection enabled.

Function Documentation

◆ R_PDM_Open()

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.

Return values
FSP_SUCCESSReady for PDM communication.
FSP_ERR_ASSERTIONThe pointer to p_ctrl or p_cfg is null.
FSP_ERR_ALREADY_OPENThe control block has already been opened.
FSP_ERR_IP_CHANNEL_NOT_PRESENTChannel number is not available on this device.
Returns
See Common Error Codes or functions called by this function for other possible return codes.

◆ R_PDM_Start()

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.

Return values
FSP_SUCCESSPDM communication stop request issued.
FSP_ERR_ASSERTIONThe pointer to p_ctrl was null.
FSP_ERR_INVALID_SIZEThe size of buffer is not a multiple of pdm_interrupt_threshold_t.
FSP_ERR_INVALID_ALIGNMENTThe alignment of argument buffer_size is not matched with hardware specification.
FSP_ERR_NOT_OPENThe channel is not opened.
Returns
See Common Error Codes or lower level drivers for other possible return codes.

◆ R_PDM_Stop()

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.

Return values
FSP_SUCCESSPDM communication stop request issued.
FSP_ERR_ASSERTIONThe pointer to p_ctrl was null.
FSP_ERR_NOT_OPENThe channel is not opened.
Returns
See Common Error Codes or lower level drivers for other possible return codes.

◆ R_PDM_SoundDetectionEnable()

fsp_err_t R_PDM_SoundDetectionEnable ( pdm_ctrl_t *const  p_ctrl,
pdm_sound_detection_setting_t  sound_detection_setting 
)

Configures and enables sound detection. Implements pdm_api_t::soundDetectionEnable.

This function configures sound detection based on the passed in settings. It then enables sound detection.

Return values
FSP_SUCCESSSound detection configured and enabled.
FSP_ERR_ASSERTIONThe pointer to p_ctrl was null.
FSP_ERR_NOT_OPENThe channel is not opened.
Returns
See Common Error Codes or lower level drivers for other possible return codes.

◆ R_PDM_SoundDetectionDisable()

fsp_err_t R_PDM_SoundDetectionDisable ( pdm_ctrl_t *const  p_ctrl)

Disables sound detection. Implements pdm_api_t::soundDetectionDisable.

This function disables sound detection.

Return values
FSP_SUCCESSSound detection disabled.
FSP_ERR_ASSERTIONThe pointer to p_ctrl was null.
FSP_ERR_NOT_OPENThe channel is not opened.
Returns
See Common Error Codes or lower level drivers for other possible return codes.

◆ R_PDM_Read()

fsp_err_t R_PDM_Read ( pdm_ctrl_t *const  p_ctrl,
void *const  p_dest,
uint32_t const  bytes 
)

This function is not supported. Implements pdm_api_t::read.

Return values
FSP_ERR_UNSUPPORTEDThis function is not supported.

◆ R_PDM_StatusGet()

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.

Calling this function will clear any set error flags in the hardware.

Return values
FSP_SUCCESSInformation stored successfully.
FSP_ERR_ASSERTIONThe p_ctrl or p_status parameter was null.
FSP_ERR_NOT_OPENThe channel is not opened.

◆ R_PDM_Close()

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.

Return values
FSP_SUCCESSDevice closed successfully.
FSP_ERR_ASSERTIONThe pointer to p_ctrl was null.
FSP_ERR_NOT_OPENThe channel is not opened.

◆ R_PDM_CallbackSet()

fsp_err_t R_PDM_CallbackSet ( pdm_ctrl_t *const  p_ctrl,
void(*)(pdm_callback_args_t *)  p_callback,
void *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

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.