Using RPI3B+. I need to have 2 pins (a clock and data) to write data to shift registers on frequencies of 1,76 MHz or rate of 1,76 Mbps, and 1 pin(connected to GPIO 18) on 20 kHz.

Tested RPi.GPIO.PWM on normal gpio pins but the response was this: Input frequency of 1000 Hz gave me about 850 Hz. 6000 Hz about 3200 Hz. It maxed out at a very unstable 6-7Khz with any extremely high number as input. So the purpose of that library is probably for lower frequencies.

[Question: Are other GPIO libraries better for creating PWM pins or writing data at these rates?]

[Edit]: I already use SPI0 for a LCD. I have 11 74hc595 shift registers daisy chained and want to have PWM output on their outputs on at least 20 kHz instead of just high and low. So I thought:

-Latch needs to be at least 20kHz.

-Clock and data synchronous on at least 8*(11 shift registers) * Latch speed = 1,76 MHz\ Mbps.

  • This question is confusing. You talk about PWM but "running shift registers on frequencies of 1,76 MHz". RPi.GPIO uses software PWM, so is slow and imprecise (but perfectly capable of controlling the brightness of a LED) - see the disclaimer at pypi.org/project/RPi.GPIO
    – Milliways
    May 5, 2021 at 8:58

1 Answer 1


If you are driving shift registers SPI will be the most efficient as you need to synchronise clock and data.

PWM is pointless as you need to have a synchronised data feed.

Using Python is not sensible if you need speed.

You could bit bang both clock and data with a C library. I doubt you would reach 1.76 Mb/s but you'd be in the right order of magnitude.

You really need to explain exactly what you want to do. Sending continuously at 1.76 Mb/s is an order of magnitude harder then sending sporadically as fast as possible.

  • Thank you for the answer. I already use SPI for an LCD so I will add a Arduino over I2C to control the shift registers.
    – aWiseMan
    May 6, 2021 at 9:30
  • The Pi has an auxiliary SPI bus on GPIO 19/20/21.
    – joan
    May 6, 2021 at 9:36
  • I added some info to my question
    – aWiseMan
    May 6, 2021 at 10:28
  • What could be downside of using the auxilirary SPI bus? Would it be very CPU intensive or interfere with SPI0?
    – aWiseMan
    May 6, 2021 at 11:31
  • No downside that I am aware of. I think it only works in SPI modes 0 and 2 but that shouldn't be a problem for shift registers.
    – joan
    May 6, 2021 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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