Skip to content

Instantly share code, notes, and snippets.

@mossmann
Last active October 27, 2019 03:22
Show Gist options
  • Save mossmann/847186da15a95bc15549637a954d90fb to your computer and use it in GitHub Desktop.
Save mossmann/847186da15a95bc15549637a954d90fb to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from greatfet import GreatFET
import time
gf = GreatFET()
# These values tune the ADF4360 to 2440.5 MHz (with a 12 MHz reference clock):
r = 24
#p = 16
a = 1
b = 305
# set up enable pin
en = gf.gpio.get_pin('J2_P24')
en.set_direction(en.DIRECTION_OUT)
en.write(1)
def write_word(word):
print("writing 0x%06x" % word)
gf.spi.transmit([
(word >> 16) & 0xff,
(word >> 8) & 0xff,
word & 0xff])
# See ADF4360 data sheet to make sense of this.
# Or don't. I'm probably going to replace it anyway.
r_counter_word = (r<<2) | 1
control_word = (1<<22) | (3<<14) | (2<<12) | (1<<11) | (1<<8) | (1<<2) | 0 #p = 16
n_counter_word = (b<<8) | (a<<2) | 2
# write configuration to ADF4360 frequency synthesizer
write_word(r_counter_word)
write_word(control_word)
time.sleep(.005)
write_word(n_counter_word)
@mossmann
Copy link
Author

mossmann commented Oct 5, 2019

This sets up Quince (4 September 2019 PCBs) for capture. After running this script, you should be able to use gf logic or something similar to sample SGPIO0 and SGPIO1 at 102 MHz. (I would like eventually to test it even faster, but 102 MHz should be sufficient and is easy to set up without reconfiguring LPC4330 clocks.) This results in a data rate of 25.5 MB/s over USB.

There are problems achieving this speed with gf logic, however: greatscottgadgets/greatfet#286

An option for testing is to use @ktemkin's sigrok implementation, but it is a bit out of date with respect to GreatFET: https://github.com/ktemkin/libsigrok/tree/wip_add_greatfet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment