bouffalolab / bouffalo_sdk

BouffaloSDK is the IOT and MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips. Also it is the combination of bl_mcu_sdk and bl_iot_sdk
Apache License 2.0
362 stars 128 forks source link

Poor AudioADC performance whenever AudioDAC or any DAC channels are enabled. #190

Open y-sh1 opened 9 months ago

y-sh1 commented 9 months ago

Hi, I was looking at the auadc_audac_loopback example, and noticed that the quality of AudioADC decreases dramatically upon initializing the AudioDAC(!)

Apparently, this problem is associated with the setting of GPDAC_CH_A and / or GPDAC_CH_B.

Specifically, the following lines of code in bflb_audac.c are causing the audac to change its behavior(!?) : if (config->output_mode & AUDAC_OUTPUT_MODE_GPDAC_CH_A) { / gpdac enable ch-A / regval = getreg32(reg_base + GLB_GPDAC_ACTRL_OFFSET); regval |= (GLB_GPDAC_A_EN | GLB_GPDAC_IOA_EN); putreg32(regval, reg_base + GLB_GPDAC_ACTRL_OFFSET); }

    if (config->output_mode & AUDAC_OUTPUT_MODE_GPDAC_CH_B) {
        /* gpdac enable ch-A */
        regval = getreg32(reg_base + GLB_GPDAC_BCTRL_OFFSET);
        regval |= (GLB_GPDAC_B_EN | GLB_GPDAC_IOB_EN);
        putreg32(regval, reg_base + GLB_GPDAC_BCTRL_OFFSET);
    }
}

It seems that by setting GPDAC_CH_A/B the AudioADC precision decreases from 16 its to 12 bits, and the pga gain is not effective.

Same issue appears whenever enabling any of the DAC Channels, for example using: bflb_dac_channel_enable(dac, DAC_CHANNEL_A); bflb_dac_channel_enable(dac, DAC_CHANNEL_B);

Any ideas?

y-sh1 commented 9 months ago

I forgot to mention that I am using BL616