2 2
fourtyseven

Is GPIO on H3 SoC really this slow?

Recommended Posts

(edited)

 

Hello, I'm new here and do not quite understand the sub-forums here but hopefully this is the right one. 

I got an Orange pi ONE running 4.19 RT kernel with Armbian buster. 

Screenshot-from-2019-11-26-12-17-27.png

I was testing out the GPIO capabilities of the H3 SoC without any libraries and got only 1.67 Mhz at best(which is ironically the same as WiringPIOP) with some task interrupt issues.

#define INP_GPIO(g) *(unsigned int *)(gpio+0x04) &= ~(7 << (((g) % 10) * 3)) 
//I did not thoroughly check if the mapping is okay 
#define OUT_GPIO(g){\
                      *(unsigned int *)(gpio+0x04)   &=  ~(6 << (((g) % 8) * 4));\
                      *(unsigned int *)(gpio+0x04)   |=   (1 << (((g) % 8) * 4));\
                   }
#define GET_GPIO(g) (*(unsigned int *)(gpio+0x10) & (1<<g))// 0 if LOW, (1<<g) if HIGH
#define GPIO_SET(g) if(!GET_GPIO(g)){*(unsigned int *)(gpio+0x10)   |= (1 << g);}
#define GPIO_CLR(g)  if(GET_GPIO(g)){*(unsigned int *)(gpio+0x10)   &= ~(1<< g);} 
//after accessing /dev/mem
OUT_GPIO(12);
for(;;)
{	  
  GPIO_SET(12);
  GPIO_CLR(12);
}

The result is pretty inconsistent but at least works (any suggestions?).

One could say remove the if statement(got 2Mhz) but that makes the output even more bizarre.

Screenshot-from-2019-11-26-12-24-44.png

At this point i am quite stuck and not sure how to get a faster result with correct timing when rising and falling. 

Any suggestions for this would be helpful.

 

Thank you! 

 

test.cpp

Edited by fourtyseven
Forgot to attach the actual code

Share this post


Link to post
Share on other sites
(edited)

Okay so after some fiddling around with registers;it seems like 1.6Mhz is the best for stability and the results seems quite consistent when the pin is checked if it actually changed the register or not.  

image.thumb.png.a274b65ba241dd041469ee6574051799.png

 

#define GET_GPIO(g) (*(unsigned int *)(gpio+0x10) & (1<<g))// 0 if LOW, (1<<g) if HIGH
#define GPIO_SET(g) if(!GET_GPIO(g)){*(unsigned int *)(gpio+0x10)   |= (1 << g);}
#define GPIO_CLR(g)  if(GET_GPIO(g)){*(unsigned int *)(gpio+0x10)   &= ~(1<< g);} 

This is still disappointing but i guess its a 'one up' from the previous results.

Edited by fourtyseven
syntax cleanup

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
2 2