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?
嗨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.
在该测试情况下,必须将SRC输出接口设置为在SRC1_CTRL_REG [SRC_OUT_AMODE]中的自动模式,在SRC中产生PDM输出时(另请参阅SRC手册和自动模式配置的DA14585数据表的表51,具体取决于使用案件)。
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
是的,我以前问过类似的问题。当时你的建议对我非常有帮助,谢谢:)。现在PDM数据结果接近正确。此处提到的测试不使用DMA,但在SRC_IN中断服务中将PCM数据写入SRC1_IN2_REG。写入SRC1_IN2_REG的PCM数据无法立即获得正确的PDM输出。相反,我需要在几个连续的SRC_IN中断中重复编写相同的PCM数据,以逐渐获得正确的PDM输出。简而言之,我得到了正确的PDM结果,但没有立即。。这让我感到困惑。
嗨Hailtao,
Let me check your issue and I will get back to you as soon as possible. Thanks for provided information.
Thanks, PM_Dialog