forked from M-Labs/humpback-dds
dds: fix full amplitude scale
This commit is contained in:
parent
649b5b498b
commit
1de13d6f3a
12
src/dds.rs
12
src/dds.rs
@ -270,13 +270,21 @@ where
|
|||||||
let resolutions :[u64; 3] = [1 << 32, 1 << 16, 1 << 14];
|
let resolutions :[u64; 3] = [1 << 32, 1 << 16, 1 << 14];
|
||||||
let ftw = (resolutions[0] * f_out / self.f_sys_clk) as u32;
|
let ftw = (resolutions[0] * f_out / self.f_sys_clk) as u32;
|
||||||
let pow = ((resolutions[1] as f64) * phase_offset / 360.0) as u16;
|
let pow = ((resolutions[1] as f64) * phase_offset / 360.0) as u16;
|
||||||
let asf = ((resolutions[2] as f64) * amp_scale_factor) as u16;
|
let asf :u16 = if amp_scale_factor == 1.0 {
|
||||||
|
0x3FFF
|
||||||
|
} else {
|
||||||
|
((resolutions[2] as f64) * amp_scale_factor) as u16
|
||||||
|
};
|
||||||
// Setup configuration registers before writing single tone register
|
// Setup configuration registers before writing single tone register
|
||||||
self.set_configurations(&mut [
|
self.set_configurations(&mut [
|
||||||
(DDSCFRMask::RAM_ENABLE, 0),
|
(DDSCFRMask::RAM_ENABLE, 0),
|
||||||
(DDSCFRMask::DIGITAL_RAMP_ENABLE, 0),
|
(DDSCFRMask::DIGITAL_RAMP_ENABLE, 0),
|
||||||
|
(DDSCFRMask::OSK_ENABLE, 0),
|
||||||
(DDSCFRMask::PARALLEL_DATA_PORT_ENABLE, 0),
|
(DDSCFRMask::PARALLEL_DATA_PORT_ENABLE, 0),
|
||||||
])?;
|
])?;
|
||||||
|
self.set_configurations(&mut [
|
||||||
|
(DDSCFRMask::EN_AMP_SCALE_SINGLE_TONE_PRO, 1),
|
||||||
|
])?;
|
||||||
// Transfer single tone profile data
|
// Transfer single tone profile data
|
||||||
self.write_register(0x0E + profile, &mut [
|
self.write_register(0x0E + profile, &mut [
|
||||||
((asf >> 8 ) & 0xFF) as u8,
|
((asf >> 8 ) & 0xFF) as u8,
|
||||||
@ -288,7 +296,7 @@ where
|
|||||||
((ftw >> 8 ) & 0xFF) as u8,
|
((ftw >> 8 ) & 0xFF) as u8,
|
||||||
((ftw >> 0 ) & 0xFF) as u8,
|
((ftw >> 0 ) & 0xFF) as u8,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user