etherkit / Si5351Arduino

Library for the Si5351 clock generator IC in the Arduino environment
GNU General Public License v3.0
233 stars 95 forks source link

pll_calc() #23

Closed akadamson closed 7 years ago

akadamson commented 8 years ago

I keep looking at this and I can't figure out what it's used for. Seems to just be code taking up space?

Middle of the above named function there is this code

    // Find best approximation for b/c = fVCO mod fIN
    denom = 1000ULL * 1000ULL;
    lltmp = freq % ref_freq;
    lltmp *= denom;
    do_div(lltmp, ref_freq);

    rfrac = lltmp;

In the ARM compiler this tells me that rfrac is initialized but never used. I actually comment out that last line with no ill effects... but it dawned on me that the entire block above it isn't used for anything, but is doing some nasty 64bit math and taking up those cycles?

Am I missing something?

NT7S commented 8 years ago

Thanks, I'll double-check that. It's possible that's some cruft left over from when I initially based the library from the Linux kernel code that I found.

NT7S commented 8 years ago

@akadamson I do believe that your analysis is correct. That code was used at one point, but when the PLL algorithm was changed, I neglected to remove it. I want to be extra certain of the impact before I remove it from production code, but I'm going to take it out of my dev branch to make sure that it has no negative impact.

NT7S commented 8 years ago

Slated for removal in 2.0.0