1

I'm writing a Linux kernel module on RPi2 to push an array to RGB Led matrix, so I want to have maximum speed of GPIO to reduce the 'flick' when it run Bit Angle Modulation. According to this site, https://github.com/hzeller/rpi-gpio-dma-demo, it's possible to output GPIO at ~41MHz if I directly write to GPIO registers like this:

// Pseudocode
ioremap(gpio_address, size);
for (;;) {
    *gpio_set_register = (1<<TOGGLE_PIN);
    *gpio_clr_register = (1<<TOGGLE_PIN);
}

But when I use this method to push the data (like software SPI) over the GPIO, the output data is incorrect. So I use writel() function instead of directly writing to the output, but the speed is now just 12MHz.

Is there any way to output GPIO at ~ 41MHz speed without being wrong?

Thank you! Sorry if my English is poor.

  • How do you know that the data it writes is incorrect, please? – Mark Smith Apr 17 at 5:47
  • I dislike these silly benchmarks of toggling GPIO. I can think of no practical application. When you want to change the GPIO you want to change them in combination with other GPIO in a coordinated sequence. From what you write you have discovered that doing that takes a lot longer than simply toggling a GPIO. – joan Apr 17 at 7:15
  • @MarkSmith I transfer data to my LED matrix then it display incorrectly, this doesn't happen if I use writel() function, or use a memory barrier wmb() before directly write to register. – msshhp Apr 17 at 16:16
  • @joan yes, I know, therefore I want to ask about a faster way than writel() function. – msshhp Apr 17 at 16:20
  • Can your matrix accept the data at that speed? – Mark Smith Apr 17 at 16:27

Your Answer

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

Browse other questions tagged or ask your own question.