I'm trying to drive a TLC5940 with a brand new RPi Model A+ (V1). I plan to use the Pi's SPI bus to pipe data to the chip, which I've done successfully before using an AVR. The part I'm stuck with is generating a regular greyscale clock for the chip at about 1MHz (the actual frequency doesn't really matter, but it's definitely in the megahertz range).

How can I get GPCLK0 (pin 7/GPIO 7) to output a 1MHz+ clock signal using rpi.gpio in Python? Ideally I'd like to be able to control the frequency.

I found this question about using GPLK0 as a clock for an ADC, however the answer is just "use a crystal" which I don't want to do. Additionally, this question about turning a GPIO to it's alternative output mode didn't help either. I did find an article that uses the one wire bus, and a forum post on how to set up the pin as a clock source in C but nothing in Python.


RPi.GPIO (as far as I am aware) has no support for setting the clocks.

You could access the raw clock device from Python using code similar to that shown at http://www.raspberrypi.org/forums/viewtopic.php?p=641670#p641670

I have an example standalone C program which sets the clock frequency "Minimal clock access" at http://abyz.me.uk/rpi/pigpio/examples.html#Misc_code. This shows the sort of functionality you'll need to port to Python.

  • Thanks for your answer. I'm going to try using the PWM pins with rpi.gpio and see where that gets me – Bojangles Nov 29 '14 at 7:35
  • 1
    @Bojangles As far as I am aware RPi.GPIO only has software timed PWM support, perhaps a few kHz. – joan Nov 29 '14 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.