Lower decimation for higher rates

This is to accomodate 300 ksps for best image rejection.
This commit is contained in:
Jan Hamal Dvořák 2024-08-06 10:18:56 +02:00
parent 36ca06f31b
commit fcc69f6a3e
2 changed files with 12 additions and 47 deletions

View file

@ -49,7 +49,7 @@ blocks:
id: variable id: variable
parameters: parameters:
comment: '' comment: ''
value: '192_000' value: '300_000'
states: states:
bus_sink: false bus_sink: false
bus_source: false bus_source: false

View file

@ -38,10 +38,10 @@
#define IQ_SAMPLES 32 #define IQ_SAMPLES 32
#define IQ_BLOCK_LEN (2 * IQ_SAMPLES) #define IQ_BLOCK_LEN (2 * IQ_SAMPLES)
#define IQ_QUEUE_LEN 4 #define IQ_QUEUE_LEN 8
#define ADC_RATE (2 * MHZ) #define ADC_RATE (2 * MHZ)
#define DECIMATE 8 #define DECIMATE 4
/* /*
* NOTE: Must have 256 phases with 256 bytes each. * NOTE: Must have 256 phases with 256 bytes each.
@ -250,60 +250,25 @@ struct IQ {
inline static int nextQ(void) inline static int nextQ(void)
{ {
static int dc = 0; return adc_fifo_get_blocking();
int x = adc_fifo_get_blocking();
int Q = ((x << 16) - dc) >> 16;
dc += Q;
return Q;
} }
inline static struct IQ next_sample() inline static struct IQ next_sample()
{ {
int I = 0, Q = 0; int I = 0, Q = 0;
int x07 = nextQ(); I += nextQ();
I += 36 * x07; Q += nextQ();
Q += 36 * x07; I -= nextQ();
Q -= nextQ();
int x06 = nextQ();
I += 0 * x06;
Q += 51 * x06;
int x05 = nextQ();
I += -36 * x05;
Q += 36 * x05;
int x04 = nextQ();
I += -51 * x04;
Q += 0 * x04;
int x03 = nextQ();
I += -36 * x03;
Q += -36 * x03;
int x02 = nextQ();
I += 0 * x02;
Q += -51 * x02;
int x01 = nextQ();
I += 36 * x01;
Q += -36 * x01;
int x00 = nextQ();
I += 51 * x00;
Q += 0 * x00;
I *= gain; I *= gain;
I >>= 8; I += 127.4 * 512;
I += 127.4 * 256; I /= 512;
I >>= 8;
Q *= gain; Q *= gain;
Q >>= 8; Q += 127.4 * 512;
Q += 127.4 * 256; Q /= 512;
Q >>= 8;
return (struct IQ){ I, Q }; return (struct IQ){ I, Q };
} }