Do not use sync out pin when using app PLL for sync mode

This commit is contained in:
Ross Owen
2023-07-14 11:55:36 +01:00
parent 2228575e09
commit d119755313
3 changed files with 18 additions and 16 deletions

View File

@@ -81,7 +81,7 @@ void XUA_Buffer_Ep(chanend c_aud_out,
#ifdef CHAN_BUFF_CTRL #ifdef CHAN_BUFF_CTRL
, chanend c_buff_ctrl , chanend c_buff_ctrl
#endif #endif
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || defined(__DOXYGEN__) #if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && !XUA_USE_APP_PLL) || defined(__DOXYGEN__)
, client interface pll_ref_if i_pll_ref , client interface pll_ref_if i_pll_ref
#endif #endif
); );

View File

@@ -358,16 +358,17 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#ifndef LOCAL_CLOCK_MARGIN #ifndef LOCAL_CLOCK_MARGIN
#define LOCAL_CLOCK_MARGIN (1000) #define LOCAL_CLOCK_MARGIN (1000)
#endif #endif
#if (XUA_USE_APP_PLL)
struct PllSettings pllSettings;
AppPllGetSettings(DEFAULT_MCLK, pllSettings);
#else
timer t_sofCheck; timer t_sofCheck;
unsigned timeLastEdge; unsigned timeLastEdge;
unsigned timeNextEdge; unsigned timeNextEdge;
t_sofCheck :> timeLastEdge; t_sofCheck :> timeLastEdge;
timeNextEdge + LOCAL_CLOCK_INCREMENT; timeNextEdge + LOCAL_CLOCK_INCREMENT;
i_pll_ref.toggle(); i_pll_ref.toggle();
#if (XUA_USE_APP_PLL)
struct PllSettings pllSettings;
AppPllGetSettings(DEFAULT_MCLK, pllSettings);
#endif #endif
#endif #endif
@@ -520,7 +521,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
} }
break; break;
} }
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && (!XUA_USE_APP_PLL)
case t_sofCheck when timerafter(timeNextEdge) :> void: case t_sofCheck when timerafter(timeNextEdge) :> void:
i_pll_ref.toggle(); i_pll_ref.toggle();
timeLastEdge = timeNextEdge; timeLastEdge = timeNextEdge;
@@ -550,12 +551,14 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
sofCount += 1000; sofCount += 1000;
if (sofCount == framesPerSec) if (sofCount == framesPerSec)
{ {
sofCount = 0;
pllUpdate++;
#if (!XUA_USE_APP_PLL)
/* Port is accessed via interface to allow flexibilty with location */ /* Port is accessed via interface to allow flexibilty with location */
i_pll_ref.toggle(); i_pll_ref.toggle();
t_sofCheck :> timeLastEdge; t_sofCheck :> timeLastEdge;
sofCount = 0;
timeNextEdge = timeLastEdge + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN; timeNextEdge = timeLastEdge + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
pllUpdate++; #endif
} }
#if (XUA_USE_APP_PLL) #if (XUA_USE_APP_PLL)
// Update PLL @ 100Hz // Update PLL @ 100Hz
@@ -671,7 +674,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
clockcounter = 0; clockcounter = 0;
} }
#else #else
/* Assuming 48kHz from a 24.576 master clock (0.0407uS period) /* Assuming 48kHz from a 24.576 master clock (0.0407uS period)
* MCLK ticks per SOF = 125uS / 0.0407 = 3072 MCLK ticks per SOF. * MCLK ticks per SOF = 125uS / 0.0407 = 3072 MCLK ticks per SOF.
* expected Feedback is 48000/8000 = 6 samples. so 0x60000 in 16:16 format. * expected Feedback is 48000/8000 = 6 samples. so 0x60000 in 16:16 format.
@@ -922,8 +924,8 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#endif #endif
#endif #endif
#if XUA_HID_ENABLED #if (XUA_HID_ENABLED)
/* HID Report Data */ /* HID Report Data */
case XUD_SetData_Select(c_hid, ep_hid, result): case XUD_SetData_Select(c_hid, ep_hid, result):
hid_ready_flag = 0U; hid_ready_flag = 0U;
unsigned reportTime; unsigned reportTime;
@@ -936,7 +938,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#endif #endif
#ifdef MIDI #ifdef MIDI
/* Received word from MIDI thread - Check for ACK or Data */ /* Received word from MIDI thread - Check for ACK or Data */
case midi_get_ack_or_data(c_midi, is_ack, datum): case midi_get_ack_or_data(c_midi, is_ack, datum):
if (is_ack) if (is_ack)
{ {

View File

@@ -145,7 +145,7 @@ on stdcore[XUD_TILE] : buffered in port:32 p_adat_rx = PORT_ADAT_IN;
on tile[XUD_TILE] : in port p_spdif_rx = PORT_SPDIF_IN; on tile[XUD_TILE] : in port p_spdif_rx = PORT_SPDIF_IN;
#endif #endif
#if (XUA_SPDIF_RX_EN) || (XUA_ADAT_RX_EN) || (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SPDIF_RX_EN) || (XUA_ADAT_RX_EN) || ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && (!XUA_USE_APP_PLL))
/* Reference to external clock multiplier */ /* Reference to external clock multiplier */
on tile[PLL_REF_TILE] : out port p_pll_ref = PORT_PLL_REF; on tile[PLL_REF_TILE] : out port p_pll_ref = PORT_PLL_REF;
#endif #endif
@@ -467,7 +467,7 @@ int main()
#endif #endif
#endif #endif
#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) #if (((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && !XUA_USE_APP_PLL) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
interface pll_ref_if i_pll_ref; interface pll_ref_if i_pll_ref;
#endif #endif
chan c_sof; chan c_sof;
@@ -491,7 +491,7 @@ int main()
{ {
USER_MAIN_CORES USER_MAIN_CORES
#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) #if (((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && XYA_USE_APP_PLL) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
on tile[PLL_REF_TILE]: PllRefPinTask(i_pll_ref, p_pll_ref); on tile[PLL_REF_TILE]: PllRefPinTask(i_pll_ref, p_pll_ref);
#endif #endif
on tile[XUD_TILE]: on tile[XUD_TILE]:
@@ -563,7 +563,7 @@ int main()
, c_xud_in[ENDPOINT_NUMBER_IN_HID] , c_xud_in[ENDPOINT_NUMBER_IN_HID]
#endif #endif
, c_mix_out , c_mix_out
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && (!XUA_USE_APP_PLL))
, i_pll_ref , i_pll_ref
#endif #endif
); );