mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
ctb fix: reset pll reset also adc and dbit phase (fixed), also required adcs to be configured again(due to adc clock being stopped temporarily
This commit is contained in:
Binary file not shown.
@ -1633,7 +1633,7 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LOG(logINFO, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
|
FILE_LOG(logDEBUG1, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
|
||||||
int valShift = val;
|
int valShift = val;
|
||||||
// convert to phase shift
|
// convert to phase shift
|
||||||
if (degrees) {
|
if (degrees) {
|
||||||
@ -1649,6 +1649,7 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
|
|||||||
FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
|
FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FILE_LOG(logINFOBLUE, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
|
||||||
|
|
||||||
int phase = 0;
|
int phase = 0;
|
||||||
if (relativePhase > 0) {
|
if (relativePhase > 0) {
|
||||||
@ -1723,15 +1724,32 @@ void configureFrequency(enum CLKINDEX ind, int val) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset phase
|
// Remembering adcphase/ dbit phase
|
||||||
if (ind == ADC_CLK || ind == DBIT_CLK) {
|
int adcPhase = getPhase(ADC_CLK, 0);
|
||||||
FILE_LOG(logINFO, ("\tReseting phase of %s\n", clock_names[ind]));
|
FILE_LOG(logDEBUG1, ("\tRemembering ADC phase: %d\n", adcPhase));
|
||||||
configurePhase(ind, 0, 0);
|
int dbitPhase = getPhase(DBIT_CLK, 0);
|
||||||
}
|
FILE_LOG(logDEBUG1, ("\tRemembering DBIT phase: %d\n", dbitPhase));
|
||||||
|
|
||||||
// Calculate and set output frequency
|
// Calculate and set output frequency
|
||||||
clkDivider[ind] = ALTERA_PLL_SetOuputFrequency (ind, PLL_VCO_FREQ_MHZ, val);
|
clkDivider[ind] = ALTERA_PLL_SetOuputFrequency (ind, PLL_VCO_FREQ_MHZ, val);
|
||||||
FILE_LOG(logINFO, ("\tC%d(%s): Frequency set to %d MHz\n", ind, clock_names[ind], clkDivider[ind]));
|
FILE_LOG(logINFO, ("\tC%d(%s): Frequency set to %d MHz\n", ind, clock_names[ind], clkDivider[ind]));
|
||||||
|
|
||||||
|
// adc and dbit phase is reset by pll (when setting output frequency)
|
||||||
|
clkPhase[ADC_CLK] = 0;
|
||||||
|
clkPhase[DBIT_CLK] = 0;
|
||||||
|
|
||||||
|
// set the phase if custom set
|
||||||
|
if (clkPhase[ADC_CLK] != adcPhase) {
|
||||||
|
FILE_LOG(logINFO, ("\tPhase reset by PLL\n\tCorrecting ADC phase to %d\n", adcPhase));
|
||||||
|
configurePhase(ADC_CLK, adcPhase, 0);
|
||||||
|
}
|
||||||
|
if (clkPhase[DBIT_CLK] != dbitPhase) {
|
||||||
|
FILE_LOG(logINFO, ("\tPhase reset by PLL\n\tCorrecting DBIT phase to %d\n", dbitPhase));
|
||||||
|
configurePhase(DBIT_CLK, dbitPhase, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// required to reconfigure as adc clock is stopped temporarily when resetting pll (in changing output frequency)
|
||||||
|
AD9257_Configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFrequency(enum CLKINDEX ind) {
|
int getFrequency(enum CLKINDEX ind) {
|
||||||
|
@ -225,7 +225,7 @@ int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
|
|||||||
// write frequency (post-scale output counter C)
|
// write frequency (post-scale output counter C)
|
||||||
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val);
|
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val);
|
||||||
|
|
||||||
// reset required to keep the phase
|
// reset required to keep the phase (must reconfigure adcs again after this as adc clock is stopped temporarily when resetting pll)
|
||||||
ALTERA_PLL_ResetPLL ();
|
ALTERA_PLL_ResetPLL ();
|
||||||
|
|
||||||
/*double temp = ((double)pllVCOFreqMhz / (double)(low_count + high_count));
|
/*double temp = ((double)pllVCOFreqMhz / (double)(low_count + high_count));
|
||||||
|
Reference in New Issue
Block a user