Issues about data out from PDM interface

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Haitao
Offline
Last seen:1 year 8 months ago
Joined:2018-06-29 01:59
Issues about data out from PDM interface

Hello,
I have been working on the driver of pdm out for a long time, but I still can not get the correct pdm out data. I modified the project DA14585_RCU_v_6.140.2.17, tried to convert some pcm data to pdm data. I made SRC_IN working in the manual mode , SRC_OUT working in the automatic mode. SRC_IN sampling rate was set to 16Khz, SRC data source was SRC_IN_REG. PDM_CLK was set to 3.2Mhz, PDM_DATA direction was PDM_DIRECTION_OUT_LEFT. SRC_IN interrupt was enabled, in the isr service function , I wrote pcm data to SRC1_IN2_REG. For the test , I just wrote the maximum vaule and minimum value alternately every 20 samples as shown below:

uint32_t const pdm_reg_value[2] = {0x800000ff, 0x7fffff00};
uint32_t pdm_out_select = 0;
void pdm_src_in_interrupt_cb_test(pdm_src_isr_data_t *src_isr_data)
{

pdm_out_select ++;
if(pdm_out_select == 40)
pdm_out_select = 0;
*(uint32_t *)SRC1_IN2_REG = pdm_reg_value[pdm_out_select/20];
...
}

and I got a wave as shown in the attachment. Writing the maximum value , I should got a all one value pdm data, Writing the minimum value, I should got a all zero value pdm data.
The data obtained by the oscilloscope show that: PDM data were not immediately reversed. I don't know why. Is it correct?

Attachment:
Device:
PM_Dialog
Offline
Last seen:3 days 12 hours ago
Staff
Joined:2018-02-08 11:03
嗨Hailtao,

嗨Hailtao,

If I remember correctly, you have recently created a similar forum thread regarding how to pcm data to pdm data. Be aware that there isn’t any available similar example, and you should do a few modifications in the RCU reference application code. Could you please let me know if you follow all the procedure that is described in the previous post? For your convenience, I will copy-paste the procedure:

The pcm data must be stored to SRC1_IN1_REG and SRC1_IN2_REG, depending on if stereo mode is intended. For the right channel only, SRC1_IN2_REG must be written. This can be done either by using ARM M0 or via the DMA.

So the change of pdm_config.direction is indeed needed, but it is not enough to produce the desired output.

为了使用DMA, av之一ailable channel pairns (0/1 or 2/3) need to be assigned to serve the SRC. For stereo mode, both channel pairs have to be assigned to SRC, to be able to write to SRC1_IN1_REG (with channel 1, for instance) and SRC1_IN2_REG (using channel 3).

Since PDM output is intended, and provided that the PCM-encoded data are located to system memory (please confirm if this is indeed the case or not in your application), only the "odd" channels (1,3) of the DMA should be activated, to write from memory to the SRC.

By not writing anything to SRC1_IN1/2_REG, and by just activating the PDM output mode, the SRC produces an output which however is not the expected one.

In this test case, the SRC output interface must be set to Automatic mode in SRC1_CTRL_REG[SRC_OUT_AMODE], when producing a PDM output from SRC (see also Table 51 of the DA14585 datasheet for the SRC manual and automatic mode configuration, depending on the use case).

Regarding the SRC input interface, it can be set to manual mode, if data are fetched by the DMA and written to the SRC input registers (see also SRC1_CTRL_REG[SRC_IN_AMODE]). This means that also the sampling rate of the SRC input interface frequency must be set accordingly in SRC1_IN_FS_REG (see also Table 52).

For getting more information about the Audio Unit, I would highly suggest you to have a look at the section 24 Audio Unit (AU) of the DA14585 datasheet Also, it would be very helpful to check the Figure 66: Audio Unit Block Diagram as well.

However, I will check again your issue and I will get back to you as soon as possible.

Thanks, PM_Dialog

Haitao
Offline
Last seen:1 year 8 months ago
Joined:2018-06-29 01:59
Yes, I've asked similar

是的,我已经问过类似的问题。你见subgestion was very helpful to me at that time, thanks : ). Now the PDM data results are close to correct. The test mentioned here does not use DMA, but writes PCM data to SRC1_IN2_REG in SRC_IN interrupt service. The PCM data written to SRC1_IN2_REG can not get the correct PDM output immediately. Instead, I need to write the same PCM data repeatedly in several continuous SRC_IN interrupts to get the correct PDM output gradually. In brief, I got the right PDM results, but not immediately. . This confuses me.

PM_Dialog
Offline
Last seen:3 days 12 hours ago
Staff
Joined:2018-02-08 11:03
嗨Hailtao,

嗨Hailtao,

Let me check your issue and I will get back to you as soon as possible. Thanks for provided information.

Thanks, PM_Dialog