Lower decimation for higher rates
This is to accomodate 300 ksps for best image rejection.
This commit is contained in:
		
							parent
							
								
									36ca06f31b
								
							
						
					
					
						commit
						fcc69f6a3e
					
				
					 2 changed files with 12 additions and 47 deletions
				
			
		|  | @ -49,7 +49,7 @@ blocks: | |||
|   id: variable | ||||
|   parameters: | ||||
|     comment: '' | ||||
|     value: '192_000' | ||||
|     value: '300_000' | ||||
|   states: | ||||
|     bus_sink: false | ||||
|     bus_source: false | ||||
|  |  | |||
							
								
								
									
										57
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								src/main.c
									
									
									
									
									
								
							|  | @ -38,10 +38,10 @@ | |||
| 
 | ||||
| #define IQ_SAMPLES 32 | ||||
| #define IQ_BLOCK_LEN (2 * IQ_SAMPLES) | ||||
| #define IQ_QUEUE_LEN 4 | ||||
| #define IQ_QUEUE_LEN 8 | ||||
| 
 | ||||
| #define ADC_RATE (2 * MHZ) | ||||
| #define DECIMATE 8 | ||||
| #define DECIMATE 4 | ||||
| 
 | ||||
| /*
 | ||||
|  * NOTE: Must have 256 phases with 256 bytes each. | ||||
|  | @ -250,60 +250,25 @@ struct IQ { | |||
| 
 | ||||
| inline static int nextQ(void) | ||||
| { | ||||
| 	static int dc = 0; | ||||
| 
 | ||||
| 	int x = adc_fifo_get_blocking(); | ||||
| 	int Q = ((x << 16) - dc) >> 16; | ||||
| 	dc += Q; | ||||
| 
 | ||||
| 	return Q; | ||||
| 	return adc_fifo_get_blocking(); | ||||
| } | ||||
| 
 | ||||
| inline static struct IQ next_sample() | ||||
| { | ||||
| 	int I = 0, Q = 0; | ||||
| 
 | ||||
| 	int x07 = nextQ(); | ||||
| 	I += 36 * x07; | ||||
| 	Q += 36 * x07; | ||||
| 
 | ||||
| 	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 += nextQ(); | ||||
| 	Q += nextQ(); | ||||
| 	I -= nextQ(); | ||||
| 	Q -= nextQ(); | ||||
| 
 | ||||
| 	I *= gain; | ||||
| 	I >>= 8; | ||||
| 	I += 127.4 * 256; | ||||
| 	I >>= 8; | ||||
| 	I += 127.4 * 512; | ||||
| 	I /= 512; | ||||
| 
 | ||||
| 	Q *= gain; | ||||
| 	Q >>= 8; | ||||
| 	Q += 127.4 * 256; | ||||
| 	Q >>= 8; | ||||
| 	Q += 127.4 * 512; | ||||
| 	Q /= 512; | ||||
| 
 | ||||
| 	return (struct IQ){ I, Q }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue