SparkFun Forums 

Where electronics enthusiasts find answers.

Everything with the AmbiqSuite SDK tools and software are welcome here.
User avatar
By TKAudioGeek
#242045
Hello there,

I am new to the world of Ambiq SoCs, SDKs and audio processing so some of the questions may seem very naïve.
I have referred Apollo 4 family programmer's guide and Apollo 4 Blue plus datasheet to understand the PDM to PCM peripheral along with the examples provided in the AmbiqSuite SDK version v4.2.0.

Referring example project pdm_fft present under AmbiqSuite_R4.2.0\boards\apollo4p_blue_evb\examples\audio from AmbiqSuite SDK v4.2.0

#define PDM_FFT_SIZE 4096 // should be padded to 16Bytes.
#define PDM_FFT_BYTES (PDM_FFT_SIZE * 4)
uint32_t g_ui32PDMDataBuffer[PDM_FFT_SIZE*2 + 3];

1. Why is the g_ui32PDMDataBuffer size is multiplied by 2 ?
2. In the above declaration of the buffer, why are we adding + 3?

3. I would appreciate if any one can explain the role of FIFO buffer used. We allocate the buffer (g_ui32PDMDataBuffer) from RAM for DMA to fill the data into and generate an interrupt once the DMA transfer is complete. I can't seem to understand the role of FIFO buffer setup done in pdm_init using the API am_hal_pdm_fifo_threshold_setup.

4. In this example the buffer allocated to fill in with data by DMA controller is used as a ping pong buffer underneath. So when does the DMA transfer complete interrupt occur? Is the buffer internally divided by half? One half is used as ping buffer and other half as pong buffer and once one of the buffer is filled DAM transfer complete interrupt is generated?

5. After receiving the DMA transfer complete interrupt data is read using int32_t, I'm guessing this is because the output from the module is 24-bit unpacked which I guess in other words mean signed 24 bit value and in order to fit this value we need int32_t. However we use uint32_t buffer (g_ui32PDMDataBuffer) to store the raw PCM data, shouldn't it be int32_t.?

Thank you.
#243051
TKAudioGeek wrote: Thu Jun 22, 2023 4:14 pm Hello there,

I am new to the world of Ambiq SoCs, SDKs and audio processing so some of the questions may seem very naïve.
I have referred Apollo 4 family programmer's guide and Apollo 4 Blue plus datasheet to understand the PDM to PCM peripheral along with the examples provided in the AmbiqSuite SDK version v4.2.0.

Referring example project pdm_fft present under AmbiqSuite_R4.2.0\boards\apollo4p_blue_evb\examples\audio from AmbiqSuite SDK v4.2.0

#define PDM_FFT_SIZE 4096 // should be padded to 16Bytes.
#define PDM_FFT_BYTES (PDM_FFT_SIZE * 4)
uint32_t g_ui32PDMDataBuffer[PDM_FFT_SIZE*2 + 3];

1. Why is the g_ui32PDMDataBuffer size is multiplied by 2 ?
2. In the above declaration of the buffer, why are we adding + 3?

3. I would appreciate if any one can explain the role of FIFO buffer used. We allocate the buffer (g_ui32PDMDataBuffer) from RAM for DMA to fill the data into and generate an interrupt once the DMA transfer is complete. I can't seem to understand the role of FIFO buffer setup done in pdm_init using the API am_hal_pdm_fifo_threshold_setup.

4. In this example the buffer allocated to fill in with data by DMA controller is used as a ping pong buffer underneath. So when does the DMA transfer complete interrupt occur? Is the buffer internally divided by half? One half is used as ping buffer and other half as pong buffer and once one of the buffer is filled DAM transfer complete interrupt is generated?

5. After receiving the DMA transfer complete interrupt data is read using int32_t, I'm guessing this is because the output from the module is 24-bit unpacked which I guess in other words mean signed 24 bit value and in order to fit this value we need int32_t. However we use uint32_t buffer (g_ui32PDMDataBuffer) to store the raw PCM data, shouldn't it be int32_t.?

Thank you.
Hello,
As per your post i give you some information please see below and folow step by step details..

1. The g_ui32PDMDataBuffer size is multiplied by 2 because it is used as a ping-pong buffer. One half is used for receiving new data while the other half is processed. This allows for continuous data acquisition and processing.
2. The "+ 3" in the buffer declaration is to account for additional space needed for padding and alignment. It ensures that the buffer size is a multiple of 16 bytes, which is necessary for efficient data handling.
3. The FIFO buffer is used to store the PDM data received from the external microphone. It acts as an intermediate storage before the data is transferred to the main buffer (g_ui32PDMDataBuffer) using DMA. The FIFO buffer helps in managing and organizing the data flow between the microphone and the main buffer.
4. In this example, the buffer is divided into two halves - ping and pong. The DMA transfer complete interrupt occurs when one half of the buffer is filled with data by the DMA controller.


I hope my suggestion is work for you, If any query please tell me i am happy to help you.
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum