From e395b747995758c2ce70c65924dcdf7cbca4f880 Mon Sep 17 00:00:00 2001 From: C-Elegans Date: Sat, 24 Jun 2017 16:13:16 -0400 Subject: Update PLL DIVF range to be [0,127] As discussed in issue #83, the range of the DIVF parameter in the iCE40 PLL Usage Guide is incorrectly listed as being 0-63, when it should actually be 0-127 when used in the SIMPLE feedback mode. This however does apply in other feedback modes, where the DIVF range should still be restricted to 0-63 --- icepll/icepll.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'icepll') diff --git a/icepll/icepll.cc b/icepll/icepll.cc index c9b1a45..744b9b1 100644 --- a/icepll/icepll.cc +++ b/icepll/icepll.cc @@ -108,6 +108,15 @@ int main(int argc, char **argv) int best_divf = 0; int best_divq = 0; + //The documentation in the iCE40 PLL Usage Guide incorrectly lists the + //maximum value of DIVF as 63, when it is only limited to 63 when using + //feedback modes other that SIMPLE. + int divf_max = 63; + if(simple_feedback) + { + divf_max = 127; + } + if (f_pllin < 10 || f_pllin > 133) { fprintf(stderr, "Error: PLL input frequency %.3f MHz is outside range 10 MHz - 133 MHz!\n", f_pllin); exit(1); @@ -123,7 +132,7 @@ int main(int argc, char **argv) double f_pfd = f_pllin / (divr + 1); if (f_pfd < 10 || f_pfd > 133) continue; - for (int divf = 0; divf <= 63; divf++) + for (int divf = 0; divf <= divf_max; divf++) { if (simple_feedback) { -- cgit v1.2.3 From 502611016ccf58498a6a8742a778531e2a0e4362 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 4 Jul 2017 12:25:41 +0200 Subject: Fix coding style in icepll.cc --- icepll/icepll.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'icepll') diff --git a/icepll/icepll.cc b/icepll/icepll.cc index 744b9b1..6b6cedb 100644 --- a/icepll/icepll.cc +++ b/icepll/icepll.cc @@ -108,14 +108,10 @@ int main(int argc, char **argv) int best_divf = 0; int best_divq = 0; - //The documentation in the iCE40 PLL Usage Guide incorrectly lists the - //maximum value of DIVF as 63, when it is only limited to 63 when using - //feedback modes other that SIMPLE. - int divf_max = 63; - if(simple_feedback) - { - divf_max = 127; - } + // The documentation in the iCE40 PLL Usage Guide incorrectly lists the + // maximum value of DIVF as 63, when it is only limited to 63 when using + // feedback modes other that SIMPLE. + int divf_max = simple_feedback ? 127 : 63; if (f_pllin < 10 || f_pllin > 133) { fprintf(stderr, "Error: PLL input frequency %.3f MHz is outside range 10 MHz - 133 MHz!\n", f_pllin); -- cgit v1.2.3