Shin 0 Posted June 19 Hi, I compared GPIO access speed between RaspberryPi4 and TinkerBoard2S. After setting GPIO1 to HIGH, I processed GPIO2 to LOW immediately. I observed the waveforms with an oscilloscope. As a result, TinkerBoard2S was much slower. I think TinkerBoard2S has better performance, but why? Please let me know if there is a way to access GPIO faster with TinkerBoard2S. The software are as follows. RaspberryPi4 ・OS RaspberryPiOS 64bit ・C language with BCM2835 library TinkerBoard2S ・OS Deabian 64bit ・C language with WiringPi library best regards, Share this post Link to post Share on other sites
tooz 52 Posted June 19 hello @Shin, the differences of the libraries might be the cause of delay. please use the following commands and see if it improves: * Console commands: //Export the GPIO pin: echo 8 > /sys/class/gpio/export //Set the GPIO pin to output mode: echo out > /sys/class/gpio/gpio8/direction //Set value to GPIO pin: echo 1 > /sys/class/gpio/gpio8/value //Read the GPIO value: cat /sys/class/gpio/gpio8/value Share this post Link to post Share on other sites
Shin 0 Posted June 24 Thank you for your reply, @tooz . I don't think this method allows for complex processing like in C programming. I would like to use GPIOs not only for turning them on and off, but also for various types of communication. Is there any way to control GPIO faster in C or Python (or other languages)? Share this post Link to post Share on other sites
tooz 52 Posted June 24 hello @Shin, will using sysfs interface suit your needs for gpio programming? Share this post Link to post Share on other sites
Shin 0 Posted June 24 hello @tooz , I have little knowledge of sysfs. Do you have sample source code? I need GPIO, I2C and SPI. Share this post Link to post Share on other sites
tooz 52 Posted June 24 hello @Shin, what's the software you're using? from the other post i saw the environment is kernel 4.4, which is quite old. i'd encourage you to use a more recent image: Tinker Board (asus.com) (the latest is debian 11 v.3.0.18 kernel 5.10) 1. to read i2c/ spi you can use 3rd party libraries such as python-periphery: https://pypi.org/project/python-periphery/ 2. to access gpio through sysfs interface, first you'll need to check the tinker board 2s pinout (see E22240_Tinker_System_2_EM_V2_WEB.pdf (asus.com) page 15 pin definitions) for example chip 0, line 8 GPIO: /sys/class/gpio/gpio8 TEST_CLKOUT2GPIO0_B07 GPIO output control example *Console commands: //Export the GPIO pin: echo 8 > /sys/class/gpio/export //Set the GPIO pin to output mode: echo out > /sys/class/gpio/gpio8/direction //Set value to GPIO pin: echo 1 > /sys/class/gpio/gpio8/value //Read the GPIO value: cat /sys/class/gpio/gpio8/value more reference on sysfs: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt both i2c & spi are in accordance with standard interfaces, if the hardware isn't working as expected, there might be an issue that needs the correct driver to enable the system more examples on how to use gpio can be found on the github wiki: https://github.com/TinkerBoard/TinkerBoard/wiki/User-Guide#gpio-config-table-for-tinker-board-2s Share this post Link to post Share on other sites
Shin 0 Posted June 27 Hello @tooz Is it possible to combine SPI/I2C control with python-periphery and GPIO control with console? GPIO is assigned to the CE pin of SPI. Therefore, I need to set up the order of SPI reading and GPIO control, and I want to control SPI and GPIO with the same software. Share this post Link to post Share on other sites