Improve frequency rounding
This commit is contained in:
parent
4b9f377bb0
commit
eb52048770
1 changed files with 3 additions and 3 deletions
|
@ -241,8 +241,8 @@ static void lo_generate_phase(uint32_t *buf, size_t len, uint32_t step, uint32_t
|
|||
|
||||
static void rx_lo_init(double freq)
|
||||
{
|
||||
double frac = (double)CLK_SYS_HZ / (8 << LO_BITS_DEPTH);
|
||||
freq = roundf(freq / frac) * frac;
|
||||
double n = round(freq * (8 << LO_BITS_DEPTH) / CLK_SYS_HZ);
|
||||
freq = n * CLK_SYS_HZ / (8 << LO_BITS_DEPTH);
|
||||
uint32_t step = freq * 4294967296.0 / CLK_SYS_HZ;
|
||||
lo_generate_phase(lo_cos, LO_WORDS, step, COS_PHASE);
|
||||
lo_generate_phase(lo_sin, LO_WORDS, step, SIN_PHASE);
|
||||
|
@ -565,7 +565,7 @@ static void do_rx()
|
|||
fwrite(block, IQ_BLOCK_LEN, 1, stdout);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
sleep_us(1);
|
||||
sleep_us(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue