mirror of
https://github.com/egzumer/uv-k5-firmware-custom
synced 2024-11-22 01:32:43 +00:00
Fix frequency band bug
This commit is contained in:
parent
19fa9718f5
commit
628f00a939
22
app/app.c
22
app/app.c
@ -447,19 +447,33 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
|
||||
if (gRxVfo->IsAM)
|
||||
{
|
||||
// RX AF level
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
|
||||
// PGA + MIXER + LNA + LNA_SHORT
|
||||
BK4819_WriteRegister(BK4819_REG_13, 3u | (3u << 3) | (2u << 5) | (3u << 8));
|
||||
// help improve AM RX audio by reducing the PGA gain
|
||||
//
|
||||
// I think the solution is to set the RX AGC to limit the front end gain
|
||||
//
|
||||
// LNA_SHORT .. 0dB
|
||||
// LNA ........ 14dB
|
||||
// MIXER ...... 0dB
|
||||
// PGA ........ -15dB
|
||||
//
|
||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (3u << 0));
|
||||
|
||||
gNeverUsed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// RX AF level
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB000 | (gEeprom.VOLUME_GAIN << 4) | (gEeprom.DAC_GAIN << 0));
|
||||
|
||||
// PGA + MIXER + LNA + LNA_SHORT
|
||||
BK4819_WriteRegister(BK4819_REG_13, 0x03BE);
|
||||
// LNA_SHORT .. 0dB
|
||||
// LNA ........ 14dB
|
||||
// MIXER ...... 0dB
|
||||
// PGA ........ -3dB
|
||||
//
|
||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
|
@ -41,12 +41,19 @@ void BK4819_Init(void)
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_00, 0x8000);
|
||||
BK4819_WriteRegister(BK4819_REG_00, 0x0000);
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
|
||||
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
|
||||
|
||||
BK4819_SetAGC(0);
|
||||
BK4819_WriteRegister(BK4819_REG_19, 0x1041);
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_19, 0b0001000001000001); // <15> MIC AGC 1 = disable 0 = enable
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_7D, 0xE940);
|
||||
|
||||
// RX AF level
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0x006F);
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0x106B);
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0x2067);
|
||||
@ -63,9 +70,12 @@ void BK4819_Init(void)
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0xD0CB);
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0xE0B5);
|
||||
BK4819_WriteRegister(BK4819_REG_09, 0xF09F);
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_1F, 0x5454);
|
||||
BK4819_WriteRegister(BK4819_REG_3E, 0xA037);
|
||||
|
||||
gBK4819_GpioOutState = 0x9000;
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_33, 0x9000);
|
||||
BK4819_WriteRegister(BK4819_REG_3F, 0);
|
||||
}
|
||||
@ -191,7 +201,13 @@ void BK4819_SetAGC(uint8_t Value)
|
||||
{
|
||||
if (Value == 0)
|
||||
{
|
||||
BK4819_WriteRegister(BK4819_REG_13, 0x03BE);
|
||||
// LNA_SHORT .. 0dB
|
||||
// LNA ........ 14dB
|
||||
// MIXER ...... 0dB
|
||||
// PGA ........ -3dB
|
||||
//
|
||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_12, 0x037B);
|
||||
BK4819_WriteRegister(BK4819_REG_11, 0x027B);
|
||||
BK4819_WriteRegister(BK4819_REG_10, 0x007A);
|
||||
@ -203,7 +219,14 @@ void BK4819_SetAGC(uint8_t Value)
|
||||
if (Value == 1)
|
||||
{
|
||||
unsigned int i;
|
||||
BK4819_WriteRegister(BK4819_REG_13, 0x03BE);
|
||||
|
||||
// LNA_SHORT .. 0dB
|
||||
// LNA ........ 14dB
|
||||
// MIXER ...... 0dB
|
||||
// PGA ........ -3dB
|
||||
//
|
||||
BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_12, 0x037C);
|
||||
BK4819_WriteRegister(BK4819_REG_11, 0x027B);
|
||||
BK4819_WriteRegister(BK4819_REG_10, 0x007A);
|
||||
@ -212,6 +235,7 @@ void BK4819_SetAGC(uint8_t Value)
|
||||
BK4819_WriteRegister(BK4819_REG_7B, 0x318C);
|
||||
BK4819_WriteRegister(BK4819_REG_7C, 0x595E);
|
||||
BK4819_WriteRegister(BK4819_REG_20, 0x8DEF);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
// Bug? The bit 0x2000 below overwrites the (i << 13)
|
||||
BK4819_WriteRegister(BK4819_REG_06, ((i << 13) | 0x2500u) + 0x036u);
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -118,8 +118,8 @@ FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||
return BAND3_136MHz;
|
||||
if (Frequency >= 10800000)
|
||||
return BAND2_108MHz;
|
||||
// if (Frequency >= 5000000)
|
||||
// return BAND1_50MHz;
|
||||
if (Frequency >= 5000000)
|
||||
return BAND1_50MHz;
|
||||
// if (Frequency >= bx_min_Hz)
|
||||
return BAND1_50MHz;
|
||||
|
||||
|
29
radio.c
29
radio.c
@ -357,6 +357,11 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
|
||||
|
||||
Frequency = pRadio->ConfigRX.Frequency;
|
||||
|
||||
#if 1
|
||||
// fix previously set incorrect band
|
||||
Band = FREQUENCY_GetBand(Frequency);
|
||||
#endif
|
||||
|
||||
if (Frequency < LowerLimitFrequencyBandTable[Band])
|
||||
Frequency = LowerLimitFrequencyBandTable[Band];
|
||||
else
|
||||
@ -481,13 +486,21 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
|
||||
break;
|
||||
}
|
||||
|
||||
// limit to 50MHz to 600MHz
|
||||
if (Frequency < 5000000)
|
||||
Frequency = 5000000;
|
||||
else
|
||||
if (Frequency > 60000000)
|
||||
Frequency = 60000000;
|
||||
|
||||
#if 0
|
||||
// limit to 50MHz to 600MHz
|
||||
if (Frequency < 5000000)
|
||||
Frequency = 5000000;
|
||||
else
|
||||
if (Frequency > 60000000)
|
||||
Frequency = 60000000;
|
||||
#else
|
||||
if (Frequency < LowerLimitFrequencyBandTable[0])
|
||||
Frequency = LowerLimitFrequencyBandTable[0];
|
||||
else
|
||||
if (Frequency > UpperLimitFrequencyBandTable[ARRAY_SIZE(UpperLimitFrequencyBandTable) - 1])
|
||||
Frequency = UpperLimitFrequencyBandTable[ARRAY_SIZE(UpperLimitFrequencyBandTable) - 1];
|
||||
#endif
|
||||
|
||||
pInfo->ConfigTX.Frequency = Frequency;
|
||||
}
|
||||
|
||||
@ -577,7 +590,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true);
|
||||
|
||||
// AF Rx Gain and DAC
|
||||
// AF RX Gain and DAC
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); // 1011 00 111010 1000
|
||||
|
||||
InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
Loading…
Reference in New Issue
Block a user