Thanks to Steve for finding the bug in my GPIO code. This patch should have the FC0012 using it's VHF/UHF filters correctly.
The difference in the UHF band is pretty stunning: http://imgur.com/a/gEutK
Cheers,
David
David Basden (1): Correctly switch UHF and VHF filters for FC0012
include/tuner_fc0012.h | 3 +++ src/rtl-sdr.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
From: David Basden davidb-git@rcpt.to
--- include/tuner_fc0012.h | 3 +++ src/rtl-sdr.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/tuner_fc0012.h b/include/tuner_fc0012.h index aa1d5e9..b4b669b 100644 --- a/include/tuner_fc0012.h +++ b/include/tuner_fc0012.h @@ -12,6 +12,9 @@ #define FC0012_BANDWIDTH_7MHZ 7 #define FC0012_BANDWIDTH_8MHZ 8
+/* Border between VHF and UHF filter bands: 300MHz */ +#define FC0012_BORDER_FREQ 300000000 + #define FC0012_LNA_GAIN_LOW 0x00 #define FC0012_LNA_GAIN_MID 0x08 #define FC0012_LNA_GAIN_HI 0x17 diff --git a/src/rtl-sdr.c b/src/rtl-sdr.c index 52adec1..e825dc7 100644 --- a/src/rtl-sdr.c +++ b/src/rtl-sdr.c @@ -43,6 +43,8 @@ typedef struct rtlsdr_tuner { int gain; /* dB */ } rtlsdr_tuner_t;
+void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val); + /* generic tuner interface functions, shall be moved to the tuner implementations */ int e4k_init(void *dev) { return e4000_Initialize(dev); } int e4k_exit(void *dev) { return 0; } @@ -53,9 +55,12 @@ int e4k_set_gain(void *dev, int gain) { return 0; } int fc0012_init(void *dev) { return FC0012_Open(dev); } int fc0012_exit(void *dev) { return 0; } int fc0012_tune(void *dev, int freq) { - /* TODO set GPIO6 accordingly */ unsigned int bw = 6; + + /* Set UHF/VHF filters through gpio6 */ + rtlsdr_set_gpio_bit(dev, 6, (freq > FC0012_BORDER_FREQ)); return FC0012_SetFrequency(dev, freq/1000, bw & 0xff); + } int fc0012_set_bw(void *dev, int bw) { unsigned long freq = ((rtlsdr_tuner_t *)dev)->freq; @@ -660,6 +665,7 @@ rtlsdr_dev_t *rtlsdr_open(uint32_t index)
/* initialise GPIOs */ rtlsdr_set_gpio_output(dev, 5); + rtlsdr_set_gpio_output(dev, 6);
/* reset tuner before probing */ rtlsdr_set_gpio_bit(dev, 5, 1);
On 02.04.2012 18:31, David Basden wrote:
Thanks to Steve for finding the bug in my GPIO code. This patch should have the FC0012 using it's VHF/UHF filters correctly.
The difference in the UHF band is pretty stunning: http://imgur.com/a/gEutK
Ah, thanks.. just committed my change a few minutes ago, thanks anyway!
Regards, Steve