diff --git a/docs/images/block-diagram.png b/docs/images/block-diagram.png index 8944d1f4..fcce0b01 100644 Binary files a/docs/images/block-diagram.png and b/docs/images/block-diagram.png differ diff --git a/docs/images/block-diagram.svg b/docs/images/block-diagram.svg index f7d5c2da..614df982 100644 --- a/docs/images/block-diagram.svg +++ b/docs/images/block-diagram.svg @@ -14,7 +14,7 @@ id="svg8" inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)" sodipodi:docname="block-diagram.svg" - inkscape:export-filename="C:\Users\Martin\Documents\hackrf\docs\images\block-diagram.png" + inkscape:export-filename="block-diagram.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96"> 2150–2750 MHz + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';stroke-width:0.264583">2170–2740 MHz 1–2150 MHz: 5–15 dBm1–2170 MHz: 5–15 dBm2150–2750 MHz: 13–15 dBm2170–2740 MHz: 13–15 dBm2750–4000 MHz: 0–5 dBm2740–4000 MHz: 0–5 dBm> 2750 MHz + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';stroke-width:0.264583">> 2740 MHz < 2150 MHz + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.175px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';stroke-width:0.264583">< 2170 MHz Diagram Revision: ADiagram Revision: B`__) - * 10 MHz to 2150 MHz: 5 dBm to 15 dBm, generally decreasing as frequency increases - * 2150 MHz to 2750 MHz: 13 dBm to 15 dBm - * 2750 MHz to 4000 MHz: 0 dBm to 5 dBm, decreasing as frequency increases + * 10 MHz to 2170 MHz: 5 dBm to 15 dBm, generally decreasing as frequency increases + * 2170 MHz to 2740 MHz: 13 dBm to 15 dBm + * 2740 MHz to 4000 MHz: 0 dBm to 5 dBm, decreasing as frequency increases * 4000 MHz to 6000 MHz: -10 dBm to 0 dBm, generally decreasing as frequency increases -Through most of the frequency range up to 4 GHz, the maximum TX power is between 0 and 10 dBm. The frequency range with best performance is 2150 MHz to 2750 MHz. +Through most of the frequency range up to 4 GHz, the maximum TX power is between 0 and 10 dBm. The frequency range with best performance is 2170 MHz to 2740 MHz. Overall, the output power is enough to perform over-the-air experiments at close range or to drive an external amplifier. If you connect an external amplifier, you should also use an external bandpass filter for your operating frequency. diff --git a/firmware/common/tuning.c b/firmware/common/tuning.c index 2739872f..4797c8b3 100644 --- a/firmware/common/tuning.c +++ b/firmware/common/tuning.c @@ -31,20 +31,22 @@ #include #include -#define FREQ_ONE_MHZ (1000 * 1000) +#define FREQ_ONE_MHZ (1000ULL * 1000) #define MIN_LP_FREQ_MHZ (0) -#define MAX_LP_FREQ_MHZ (2150) +#define MAX_LP_FREQ_MHZ (2170ULL) -#define MIN_BYPASS_FREQ_MHZ (2150) -#define MAX_BYPASS_FREQ_MHZ (2750) +#define ABS_MIN_BYPASS_FREQ_MHZ (2150ULL) +#define MIN_BYPASS_FREQ_MHZ (MAX_LP_FREQ_MHZ) +#define MAX_BYPASS_FREQ_MHZ (2740ULL) +#define ABS_MAX_BYPASS_FREQ_MHZ (2750ULL) -#define MIN_HP_FREQ_MHZ (2750) -#define MID1_HP_FREQ_MHZ (3600) -#define MID2_HP_FREQ_MHZ (5100) -#define MAX_HP_FREQ_MHZ (7250) +#define MIN_HP_FREQ_MHZ (MAX_BYPASS_FREQ_MHZ) +#define MID1_HP_FREQ_MHZ (3600ULL) +#define MID2_HP_FREQ_MHZ (5100ULL) +#define MAX_HP_FREQ_MHZ (7250ULL) -#define MIN_LO_FREQ_HZ (84375000) +#define MIN_LO_FREQ_HZ (84375000ULL) #define MAX_LO_FREQ_HZ (5400000000ULL) static uint32_t max2837_freq_nominal_hz = 2560000000; @@ -63,8 +65,8 @@ bool set_freq(const uint64_t freq) uint32_t MAX2837_freq_hz; uint64_t real_mixer_freq_hz; - const uint32_t freq_mhz = freq / 1000000; - const uint32_t freq_hz = freq % 1000000; + const uint32_t freq_mhz = freq / FREQ_ONE_MHZ; + const uint32_t freq_hz = freq % FREQ_ONE_MHZ; success = true; @@ -73,10 +75,10 @@ bool set_freq(const uint64_t freq) if (freq_mhz < MAX_LP_FREQ_MHZ) { rf_path_set_filter(&rf_path, RF_PATH_FILTER_LOW_PASS); #ifdef RAD1O - max2837_freq_nominal_hz = 2300000000; + max2837_freq_nominal_hz = 2300 * FREQ_ONE_MHZ; #else - /* IF is graduated from 2650 MHz to 2343 MHz */ - max2837_freq_nominal_hz = 2650000000 - (freq / 7); + /* IF is graduated from 2650 MHz to 2340 MHz */ + max2837_freq_nominal_hz = (2650 * FREQ_ONE_MHZ) - (freq / 7); #endif mixer_freq_mhz = (max2837_freq_nominal_hz / FREQ_ONE_MHZ) + freq_mhz; /* Set Freq and read real freq */ @@ -91,15 +93,18 @@ bool set_freq(const uint64_t freq) sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0); } else if ((freq_mhz >= MIN_HP_FREQ_MHZ) && (freq_mhz <= MAX_HP_FREQ_MHZ)) { if (freq_mhz < MID1_HP_FREQ_MHZ) { - /* IF is graduated from 2150 MHz to 2750 MHz */ - max2837_freq_nominal_hz = - 2150000000 + (((freq - 2750000000) * 60) / 85); + /* IF is graduated from 2170 MHz to 2740 MHz */ + max2837_freq_nominal_hz = (MIN_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ) + + (((freq - (MAX_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ)) * 57) / + 86); } else if (freq_mhz < MID2_HP_FREQ_MHZ) { /* IF is graduated from 2350 MHz to 2650 MHz */ - max2837_freq_nominal_hz = 2350000000 + ((freq - 3600000000) / 5); + max2837_freq_nominal_hz = (2350 * FREQ_ONE_MHZ) + + ((freq - (MID1_HP_FREQ_MHZ * FREQ_ONE_MHZ)) / 5); } else { /* IF is graduated from 2500 MHz to 2738 MHz */ - max2837_freq_nominal_hz = 2500000000 + ((freq - 5100000000) / 9); + max2837_freq_nominal_hz = (2500 * FREQ_ONE_MHZ) + + ((freq - (MID2_HP_FREQ_MHZ * FREQ_ONE_MHZ)) / 9); } rf_path_set_filter(&rf_path, RF_PATH_FILTER_HIGH_PASS); mixer_freq_mhz = freq_mhz - (max2837_freq_nominal_hz / FREQ_ONE_MHZ); @@ -127,8 +132,8 @@ bool set_freq_explicit( const uint64_t lo_freq_hz, const rf_path_filter_t path) { - if ((if_freq_hz < ((uint64_t) MIN_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ)) || - (if_freq_hz > ((uint64_t) MAX_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ))) { + if ((if_freq_hz < ((uint64_t) ABS_MIN_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ)) || + (if_freq_hz > ((uint64_t) ABS_MAX_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ))) { return false; } diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index a2ad9ccc..ed2a0836 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -94,8 +94,10 @@ int gettimeofday(struct timeval* tv, void* ignored) #define FREQ_MIN_HZ (1000000ll) /* 1MHz */ #define FREQ_MAX_HZ (6000000000ll) /* 6000MHz */ #define FREQ_ABS_MAX_HZ (7250000000ll) /* 7250MHz */ -#define IF_MIN_HZ (2150000000ll) -#define IF_MAX_HZ (2750000000ll) +#define IF_ABS_MIN_HZ (2150000000ll) +#define IF_MIN_HZ (2170000000ll) +#define IF_MAX_HZ (2740000000ll) +#define IF_ABS_MAX_HZ (2750000000ll) #define LO_MIN_HZ (84375000ll) #define LO_MAX_HZ (5400000000ll) #define DEFAULT_LO_HZ (1000000000ll) @@ -664,9 +666,11 @@ static void usage() u64toa((FREQ_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[1]), u64toa((FREQ_ABS_MIN_HZ / FREQ_ONE_MHZ), &ascii_u64_data[2]), u64toa((FREQ_ABS_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[3])); - printf("\t[-i if_freq_hz] # Intermediate Frequency (IF) in Hz [%sMHz to %sMHz].\n", + printf("\t[-i if_freq_hz] # Intermediate Frequency (IF) in Hz [%sMHz to %sMHz supported, %sMHz to %sMHz forceable].\n", u64toa((IF_MIN_HZ / FREQ_ONE_MHZ), &ascii_u64_data[0]), - u64toa((IF_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[1])); + u64toa((IF_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[1]), + u64toa((IF_ABS_MIN_HZ / FREQ_ONE_MHZ), &ascii_u64_data[2]), + u64toa((IF_ABS_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[3])); printf("\t[-o lo_freq_hz] # Front-end Local Oscillator (LO) frequency in Hz [%sMHz to %sMHz].\n", u64toa((LO_MIN_HZ / FREQ_ONE_MHZ), &ascii_u64_data[0]), u64toa((LO_MAX_HZ / FREQ_ONE_MHZ), &ascii_u64_data[1])); @@ -920,14 +924,23 @@ int main(int argc, char** argv) usage(); return EXIT_FAILURE; } - if ((if_freq_hz > IF_MAX_HZ) || (if_freq_hz < IF_MIN_HZ)) { + if (((if_freq_hz > IF_MAX_HZ) || (if_freq_hz < IF_MIN_HZ)) && + !force_ranges) { fprintf(stderr, - "argument error: if_freq_hz shall be between %s and %s.\n", + "argument error: if_freq_hz should be between %s and %s.\n", u64toa(IF_MIN_HZ, &ascii_u64_data[0]), u64toa(IF_MAX_HZ, &ascii_u64_data[1])); usage(); return EXIT_FAILURE; } + if ((if_freq_hz > IF_ABS_MAX_HZ) || (if_freq_hz < IF_ABS_MIN_HZ)) { + fprintf(stderr, + "argument error: if_freq_hz must be between %s and %s.\n", + u64toa(IF_ABS_MIN_HZ, &ascii_u64_data[0]), + u64toa(IF_ABS_MAX_HZ, &ascii_u64_data[1])); + usage(); + return EXIT_FAILURE; + } if ((lo_freq_hz > LO_MAX_HZ) || (lo_freq_hz < LO_MIN_HZ)) { fprintf(stderr, "argument error: lo_freq_hz shall be between %s and %s.\n", @@ -966,7 +979,7 @@ int main(int argc, char** argv) u64toa(freq_hz, &ascii_u64_data[0])); } else if (automatic_tuning) { - if (((freq_hz > FREQ_MAX_HZ) | (freq_hz < FREQ_MIN_HZ)) && + if (((freq_hz > FREQ_MAX_HZ) || (freq_hz < FREQ_MIN_HZ)) && !force_ranges) { fprintf(stderr, "argument error: freq_hz should be between %s and %s.\n", diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 30226162..5dca56fb 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -1456,6 +1456,13 @@ int ADDCALL hackrf_set_freq_explicit( uint8_t length; int result; + /* + * Restriction to the range 2170-2740 MHz is strongly recommended for + * HackRF One and Jawbreaker. We permit IF as low as 2150 MHz and as + * high as 2750 MHz for backwards compatibility and for + * experimentation, but settings outside the recommended range may not + * work on all devices. + */ if (if_freq_hz < 2150000000 || if_freq_hz > 2750000000) { return HACKRF_ERROR_INVALID_PARAM; }