Fixed IF Shift Bug (USB and TX Mode)

This commit is contained in:
phdlee 2018-03-19 21:35:41 +09:00
parent bd52de59d2
commit ecd104b686
3 changed files with 39 additions and 17 deletions

View File

@ -492,28 +492,29 @@ void setTXFilters(unsigned long freq){
void setFrequency(unsigned long f){ void setFrequency(unsigned long f){
f = (f / arTuneStep[tuneStepIndex -1]) * arTuneStep[tuneStepIndex -1]; f = (f / arTuneStep[tuneStepIndex -1]) * arTuneStep[tuneStepIndex -1];
setTXFilters(f); setTXFilters(f);
unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
if (cwMode == 0) if (cwMode == 0)
{ {
if (isUSB){ if (isUSB){
si5351bx_setfreq(2, SECOND_OSC_USB - usbCarrier + f + (isIFShift ? ifShiftValue : 0)); si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_USB); si5351bx_setfreq(1, SECOND_OSC_USB);
} }
else{ else{
si5351bx_setfreq(2, SECOND_OSC_LSB + usbCarrier + f + (isIFShift ? ifShiftValue : 0)); si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_LSB); si5351bx_setfreq(1, SECOND_OSC_LSB);
} }
} }
else else
{ {
if (cwMode == 1){ //CWL if (cwMode == 1){ //CWL
si5351bx_setfreq(2, SECOND_OSC_LSB + cwmCarrier + f + (isIFShift ? ifShiftValue : 0)); si5351bx_setfreq(2, SECOND_OSC_LSB + appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_LSB); si5351bx_setfreq(1, SECOND_OSC_LSB);
} }
else{ //CWU else{ //CWU
si5351bx_setfreq(2, SECOND_OSC_USB - cwmCarrier + f + (isIFShift ? ifShiftValue : 0)); si5351bx_setfreq(2, SECOND_OSC_USB - appliedCarrier + f);
si5351bx_setfreq(1, SECOND_OSC_USB); si5351bx_setfreq(1, SECOND_OSC_USB);
} }
} }
@ -543,7 +544,9 @@ void startTx(byte txMode, byte isDisplayUpdate){
ritRxFrequency = frequency; ritRxFrequency = frequency;
setFrequency(ritTxFrequency); setFrequency(ritTxFrequency);
} }
else if (splitOn == 1) { else
{
if (splitOn == 1) {
if (vfoActive == VFO_B) { if (vfoActive == VFO_B) {
vfoActive = VFO_A; vfoActive = VFO_A;
frequency = vfoA; frequency = vfoA;
@ -554,10 +557,12 @@ void startTx(byte txMode, byte isDisplayUpdate){
frequency = vfoB; frequency = vfoB;
byteToMode(vfoB_mode, 0); byteToMode(vfoB_mode, 0);
} }
}
setFrequency(frequency); setFrequency(frequency);
} //end of else } //end of else
SetCarrierFreq();
if (txMode == TX_CW){ if (txMode == TX_CW){
//turn off the second local oscillator and the bfo //turn off the second local oscillator and the bfo
@ -595,14 +600,19 @@ void stopTx(void){
digitalWrite(TX_RX, 0); //turn off the tx digitalWrite(TX_RX, 0); //turn off the tx
/*
if (cwMode == 0) if (cwMode == 0)
si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off
else else
si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off
*/
SetCarrierFreq();
if (ritOn) if (ritOn)
setFrequency(ritRxFrequency); setFrequency(ritRxFrequency);
else if (splitOn == 1) { else
{
if (splitOn == 1) {
//vfo Change //vfo Change
if (vfoActive == VFO_B){ if (vfoActive == VFO_B){
vfoActive = VFO_A; vfoActive = VFO_A;
@ -614,10 +624,10 @@ void stopTx(void){
frequency = vfoB; frequency = vfoB;
byteToMode(vfoB_mode, 0); byteToMode(vfoB_mode, 0);
} }
setFrequency(frequency); }
} //end of else
else
setFrequency(frequency); setFrequency(frequency);
} //end of else
updateDisplay(); updateDisplay();
} }

View File

@ -306,10 +306,13 @@ void menuSelectMode(int btn){
FrequencyToVFO(1); FrequencyToVFO(1);
} }
/*
if (cwMode == 0) if (cwMode == 0)
si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off
else else
si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0)); //set back the carrier oscillator anyway, cw tx switches it off
*/
SetCarrierFreq();
setFrequency(frequency); setFrequency(frequency);
menuClearExit(500); menuClearExit(500);

View File

@ -124,15 +124,24 @@ void si5351_set_calibration(int32_t cal){
si5351bx_setfreq(0, usbCarrier); si5351bx_setfreq(0, usbCarrier);
} }
void SetCarrierFreq()
{
unsigned long appliedCarrier = ((cwMode == 0 ? usbCarrier : cwmCarrier) + (isIFShift && (inTx == 0) ? ifShiftValue : 0));
si5351bx_setfreq(0, appliedCarrier);
/*
if (cwMode == 0)
si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0));
else
si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0));
*/
}
void initOscillators(){ void initOscillators(){
//initialize the SI5351 //initialize the SI5351
si5351bx_init(); si5351bx_init();
si5351bx_vcoa = (SI5351BX_XTAL * SI5351BX_MSA) + calibration; // apply the calibration correction factor si5351bx_vcoa = (SI5351BX_XTAL * SI5351BX_MSA) + calibration; // apply the calibration correction factor
SetCarrierFreq();
if (cwMode == 0)
si5351bx_setfreq(0, usbCarrier + (isIFShift ? ifShiftValue : 0));
else
si5351bx_setfreq(0, cwmCarrier + (isIFShift ? ifShiftValue : 0));
} }
//============================================================ //============================================================