Skip to content

Instantly share code, notes, and snippets.

@dtbartle
Created March 17, 2014 10:18
Show Gist options
  • Save dtbartle/5319985b29b7f78c3993 to your computer and use it in GitHub Desktop.
Save dtbartle/5319985b29b7f78c3993 to your computer and use it in GitHub Desktop.
Generates all frequencies and frequency commands resulting from all possible values of pll_R, pll_F, and pll_OD.
#!/usr/bin/python
import struct
Fin = 25
print 'Fout\tcmd\t\t\tpll_R\tpll_F\tpll_OD'
for pll_R in xrange(0, 32):
for pll_F in xrange(0, 128):
for pll_OD in xrange(4):
Fref = int(Fin / (pll_R + 1))
Fvco = int(Fref * (pll_F + 1))
Fout = int(Fvco / (1 << pll_OD))
if Fout < 500: continue
pll_BS = 1 if Fvco >= 500 else 0
val = 1 | 4 | (pll_R << 16) | (pll_F << 21) | (pll_OD << 28) | (pll_BS << 31)
cmd = struct.unpack(">I", struct.pack("<I", val))[0]
print '%d\t55AAEF00%.8X\t%d\t%d\t%d' % (Fout, cmd, pll_R, pll_F, pll_OD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment