diff --git a/module_usb_audio/ports/audioports.xc b/module_usb_audio/ports/audioports.xc index 5717afc1..515deaca 100644 --- a/module_usb_audio/ports/audioports.xc +++ b/module_usb_audio/ports/audioports.xc @@ -1,5 +1,6 @@ #include #include +#include #include "devicedefines.h" #include "audioports.h" @@ -34,12 +35,22 @@ unsigned int divide) /* Output 0 on BCLK to ensure clock is low * Required as stop_clock will only complete when the clock is low */ - configure_out_port_no_ready(p_bclk, clk_audio_mclk, 0); - p_bclk <: 0; - - /* Stop bit and master clock blocks and clear port buffers */ + // configure_out_port_no_ready(p_bclk, clk_audio_mclk, 0); + // p_bclk <: 0; + + /* Stop_clock() will not complete if the source to the clock-block is not low + * since we are switching between DSD and I2S we grab the source from the clock + * -block and set it low + */ + { + unsigned clockResId; + unsigned portResId; + asm("add %0, %1, %2": "=r"(clockResId):"r"(clk_audio_bclk), "r"(0)); + portResId = getps(clockResId | (XS1_RES_PS_CLKSRC << 4) ); + if(portResId !=1) + asm("out res[%0], %1":: "r"(portResId), "r"(0)); + } stop_clock(clk_audio_bclk); - //stop_clock(clk_audio_mclk); if(!isnull(p_lrclk)) {