diff --git a/grc/PicoSDR-WBFM.grc b/grc/PicoSDR-WBFM.grc index 9ade9bd..7f2a5c0 100644 --- a/grc/PicoSDR-WBFM.grc +++ b/grc/PicoSDR-WBFM.grc @@ -374,7 +374,7 @@ blocks: freq7: 100e6 freq8: 100e6 freq9: 100e6 - gain0: '0' + gain0: '30' gain1: '10' gain10: '10' gain11: '10' diff --git a/src/main.c b/src/main.c index f63d094..a4b3bc3 100644 --- a/src/main.c +++ b/src/main.c @@ -22,7 +22,7 @@ #include #define VREG_VOLTAGE VREG_VOLTAGE_1_20 -#define CLK_SYS_HZ (288 * MHZ) +#define CLK_SYS_HZ (300 * MHZ) #define INIT_SAMPLE_RATE 200000 #define INIT_FREQ 94600000 @@ -559,11 +559,13 @@ inline static struct IQ next_sample() I *= gain; I /= 1024; I *= max_amplitude_mul; + I += 127.4 * (1 << 16); I /= (1 << 16); Q *= gain; Q /= 1024; Q *= max_amplitude_mul; + Q += 127.4 * (1 << 16); Q /= (1 << 16); return (struct IQ){ I, Q }; @@ -586,19 +588,19 @@ static void rf_rx(void) int64_t I = IQ.I; int64_t Q = IQ.Q; - if (I > 127) - I = 127; - else if (I < -128) - I = -128; + if (I < 0) + I = 0; + else if (I > 255) + I = 255; - *blockptr++ = (uint8_t)I + 128; + *blockptr++ = I; - if (Q > 127) - Q = 127; - else if (Q < -128) - Q = -128; + if (Q < 0) + Q = 0; + else if (Q > 255) + Q = 255; - *blockptr++ = (uint8_t)Q + 128; + *blockptr++ = Q; } if (queue_try_add(&iq_queue, &block)) {