mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-12-27 03:18:30 +01:00
tuner_fc001x: check if PLL values are within boundaries
This fixes the issue of the FC0013 locking up at frequencies between 928.0 and 950.0 MHz, which happened because the numerator of the fraction exceeded its 5 bit limit. For the tuner to behave normally again, the dongle needed to be replugged. For the FC0013 this now results in a small gap between 948.6 MHz and 950.0 MHz, where no valid PLL values are existant. For the FC0012 tuning is aborted when the maximum frequency has been reached (948.6 MHz). Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
01d8d308fc
commit
a943a2ed25
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "rtlsdr_i2c.h"
|
#include "rtlsdr_i2c.h"
|
||||||
#include "tuner_fc0012.h"
|
#include "tuner_fc0012.h"
|
||||||
@ -215,12 +216,23 @@ int fc0012_set_params(void *dev, uint32_t freq, uint32_t bandwidth)
|
|||||||
am = (uint8_t)(xdiv - (8 * pm));
|
am = (uint8_t)(xdiv - (8 * pm));
|
||||||
|
|
||||||
if (am < 2) {
|
if (am < 2) {
|
||||||
reg[1] = am + 8;
|
am += 8;
|
||||||
reg[2] = pm - 1;
|
pm--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pm > 31) {
|
||||||
|
reg[1] = am + (8 * (pm - 31));
|
||||||
|
reg[2] = 31;
|
||||||
} else {
|
} else {
|
||||||
reg[1] = am;
|
reg[1] = am;
|
||||||
reg[2] = pm;
|
reg[2] = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reg[1] > 15) {
|
||||||
|
fprintf(stderr, "[FC0012] no valid PLL combination "
|
||||||
|
"found for %u Hz!\n", freq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* fix for frequency less than 45 MHz */
|
/* fix for frequency less than 45 MHz */
|
||||||
reg[1] = 0x06;
|
reg[1] = 0x06;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "rtlsdr_i2c.h"
|
#include "rtlsdr_i2c.h"
|
||||||
#include "tuner_fc0013.h"
|
#include "tuner_fc0013.h"
|
||||||
@ -320,12 +321,23 @@ int fc0013_set_params(void *dev, uint32_t freq, uint32_t bandwidth)
|
|||||||
am = (uint8_t)(xdiv - (8 * pm));
|
am = (uint8_t)(xdiv - (8 * pm));
|
||||||
|
|
||||||
if (am < 2) {
|
if (am < 2) {
|
||||||
reg[1] = am + 8;
|
am += 8;
|
||||||
reg[2] = pm - 1;
|
pm--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pm > 31) {
|
||||||
|
reg[1] = am + (8 * (pm - 31));
|
||||||
|
reg[2] = 31;
|
||||||
} else {
|
} else {
|
||||||
reg[1] = am;
|
reg[1] = am;
|
||||||
reg[2] = pm;
|
reg[2] = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reg[1] > 15) {
|
||||||
|
fprintf(stderr, "[FC0013] no valid PLL combination "
|
||||||
|
"found for %u Hz!\n", freq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* fix for frequency less than 45 MHz */
|
/* fix for frequency less than 45 MHz */
|
||||||
reg[1] = 0x06;
|
reg[1] = 0x06;
|
||||||
|
Loading…
Reference in New Issue
Block a user