GPIO very slow - Raspberry Pi Forums


i tried following code see raspberry speed using <chrono> library (i added full code file):

code: select all

	for (i=0;i<maxi;i++) 	{ 		pone_puerto(3,1);               //writesgpio3 high 		while( lee_puerto(2)!=1) j++; //waits until gpio2 high 		pone_puerto(3,0);                 //writes @ gpio3 low 		while( lee_puerto(2)!=0) j++;//waits until gpio2 low 	} 


pone_puerto() function writes @ gpio port and
lee_puerto() function reads @ gpio port accordingly:

code: select all

int lee_puerto(int puerto) { if (rpigpio1.readpin(puerto) == mmapgpio::high) return 1;else return 0;} void pone_puerto(int puerto,int estado) { if (estado) rpigpio1.writepinhigh(puerto );else rpigpio1.writepinlow( puerto );} 
placed bridge between ports gpio2 , 3
obtained pin going , low every 2.57mhz (without overclocking)

found 1 read gpio port performed @ 6.63mhz !!!
writting port lot more quick: 18.56mhz

here compilation flags:
//compilation: g++ -pthread -std=c++11 -o3 -t4 -wall -c "%f"
//build: g++ -pthread -std=c++11 -wall -o "%e" "%f"
//execute: sudo "./%e"
why rpigpio1.readpin(port) slow?

simple.

going through several layers of libraries.

if use bcm libraries, faster.

if use assembly code, faster.

but

running under linux, , core interrupted @ times, cannot generate precise timing without jitter (unless start using dma)


raspberrypi



Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code