2 years ago
Issues about data out from PDM interface
Posted byHaitao0 points 3 repliesHello,
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 | Size |
---|---|
pdm out.pdf | 520.32 KB |
2 years ago
Yes, I've asked similar questions before. Your suggestion 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.
2 years ago
嗨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.
In order to use the DMA, one of the available 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.
不写任何SRC1_IN1/2_REG和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