mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
use atan2 for pll phase error
This commit is contained in:
@@ -30,7 +30,7 @@ float apply_pll(PLL *pll, float ref_sample) {
|
||||
float vco_output = sinf(pll->phase);
|
||||
if (pll->quadrature_mode) vco_output = sinf(pll->phase + (M_PI / 2.0f));
|
||||
|
||||
phase_error = ref_sample * vco_output;
|
||||
phase_error = atan2f(ref_sample, vco_output);;
|
||||
|
||||
pll->loop_filter_state += pll->ki * phase_error / pll->sample_rate;
|
||||
float loop_output = pll->loop_filter_state + pll->kp * phase_error;
|
||||
|
||||
Reference in New Issue
Block a user