Skip to content

Instantly share code, notes, and snippets.

@DexterHaslem
Created August 12, 2020 19:59
Show Gist options
  • Save DexterHaslem/e0b31747f51985c44768ccc3d3e11f05 to your computer and use it in GitHub Desktop.
Save DexterHaslem/e0b31747f51985c44768ccc3d3e11f05 to your computer and use it in GitHub Desktop.
import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
# getting pi 3 or later (bcm2835 +) to generate 1 MHz spi clock is possible, but stupid:
# setting to 1.6 MHz math works out generating a 1 MHz clock output..
hz = 1600000
i = 0
while True:
spi.max_speed_hz = hz
d = [0xFA] * 4096
spi.xfer(d)
#print('hz = {}, i= {}'.format(hz, i))
#hz += 100000
#i = i + 1
#if hz >= 2000000:
# hz = 100000
time.sleep(0.33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment