Toggle GPIO pins of MYS-8MMX Single Board Computer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Toggle GPIO pins of MYS-8MMX Single Board Computer

2,128 次查看
kundan
Contributor II

Hello  @everyone

I'm kundan from india, i just bought a single board computer board (MYS-8MMX). I dont know how can i start. I just want to check the maximum GPIO toggle speed.

In Rpi difference between rising and falling edge in 30ns i am getting, same thing i want to test in this board. Rpi is not suitable for my project.

       __          __          __         __
___|    |____|    |____|     |___|     |___

      |    | <-- 30ns difference

So, please suggest me how can i start coding in this board, i am using ubuntu 18 image.

 

 

Thank you

Kundan jha

0 项奖励
回复
11 回复数

1,915 次查看
kundan
Contributor II

Hii,

Now i can toggle gpio pin, but toggle speed is very slow, can you suggest me how can do more fast toggling. Actually i am getting GPIO rising and falling edge difference is ~1microsecond and i need in ~20 nanosecond. i am attaching my current code for the reference.

gpiod_line_set_value(line, val); //This function call taking more time, how can i reduce.

0 项奖励
回复

2,052 次查看
kundan
Contributor II

hi @Sanket_Parekh ,

can you please help me how can i get the line number for MYS-8mmx sbc,

example : 

char *chipname = "gpiochip0";
unsigned int line_num = 23; // GPIO Pin #23
unsigned int val;
struct gpiod_chip *chip;
struct gpiod_line *line;
0 项奖励
回复

2,031 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @kundan,

I hope you are doing well.

"can you please help me how can i get the line number for MYS-8mmx sbc,"
->Please correct my understanding if it's wrong, you want to get the unsigned line_num that is gpio pin, basically you wanna perform toggling on, right?

If yes, then one can refer to the below link in which there are a few examples given one can take reference from.
https://blog.lxsang.me/post/id/33
https://community.nxp.com/t5/i-MX-Processors/iMX6SL-GPIO-How-to-use-the-GPIO-from-userspace/m-p/4542...

I hope this helps!

Thanks & Regards,
Sanket Parekh

0 项奖励
回复

2,018 次查看
kundan
Contributor II
yes correct, thank you for your references, I am checking it should work.
Thank you!
0 项奖励
回复

2,009 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @kundan,

I hope you are doing well.

Yes, Sure, Please share the updates from your side, If any.

Thanks & Regards,
Sanket Parekh

0 项奖励
回复

2,004 次查看
kundan
Contributor II

Hi @Sanket_Parekh ,

Thanks for your suggestions!!

I am going with this link : https://blog.lxsang.me/post/id/33.

This is compiled properly. 

Now i am getting this: 
root@bionic-arm64:/root/test# vi openchr_device.c
root@bionic-arm64:/root/test# gcc openchr_device.c
root@bionic-arm64:/root/test# ./a.out
Usage: ./a.out options dev_name.
Options:
-i: print gpio chip info
-r <offset>: Read GPIO value at offset (INPUT mode)
-w <offset>: Write GPIO value at offset (OUTPUT mode). Option -v should be set
-v <0|1>: value that should be written to the GPIO, used only with option -w
-p <offset>: Polling raising event on the GPIO at offset
 

then next i provided below command and got 

root@bionic-arm64:/root/test# ./a.out -i /dev/gpiochip0
Chip name: gpiochip0
Chip label: 30200000.gpio
Number of lines: 32
offset: 0, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 1, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 2, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 3, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 4, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 5, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 6, name: , consumer: . Flags: [OUTPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 7, name: , consumer: . Flags: [OUTPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 8, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 9, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 10, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 11, name: , consumer: . Flags: [OUTPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 12, name: , consumer: . Flags: [OUTPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 13, name: , consumer: reset. Flags: [OUTPUT] [ACTIVE_LOW] [...] [...] [KERNEL]
offset: 14, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 15, name: , consumer: sd1_regulator. Flags: [OUTPUT] [ACTIVE_HIGHT] [...] [...] [KERNEL]
offset: 16, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 17, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 18, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 19, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 20, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 21, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 22, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 23, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 24, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 25, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 26, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 27, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 28, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 29, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 30, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []
offset: 31, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT] [...] [...] []

Now i want to write 0 & 1 on the gpio pins. What should i do next.

 

 

0 项奖励
回复

1,900 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @kundan,

I hope you are doing well.
Please accept my apology for the delayed response.

"i don't know GPIO pin number,  is it offset?"
Yes based on the link you have followed it would look like given below.
offset: 0, name: , consumer: . Flags: [INPUT] [ACTIVE_HIGHT]

So here please try with the pin number you wanted to check with.

It should work according to the command I suggested.

I hope it helps!

Thanks & Regards,

Sanket Parekh

0 项奖励
回复

1,889 次查看
kundan
Contributor II
Hi @Sanket_Parekh,
Thanks for your response, I was waiting.
Using this process I am not able to write on GPIO pin, I'm getting error "Unable to open".
Now I moved and using libgpiod. Using this method i can toggle gpio but speed not matching my requirement. I mentioned already. Please see my previous reply.
0 项奖励
回复

1,834 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @kundan,

I hope you are doing well.

"can you suggest me how can do more fast toggling."
->Please refer to the below link.
https://community.nxp.com/t5/i-MX-Processors/imx6-How-to-make-GPIO-toggle-faster/m-p/309313

I hope it helps!

Thanks & Regards,

Sanket Parekh

0 项奖励
回复

2,064 次查看
kundan
Contributor II

Hello @Sanket_Parekh

Thank you for this suggestions!!

Now  i can able to toggle the GPIO pin. But  only toggle using command "echo 1 > value" from sys/class/gpio path. and also in script to toggle a GPIO pin. But in this way i am not able to achieve the maximum toggle speed. Can you suggest me another way.

Thanks & Regards,

Kundan Jha

 

0 项奖励
回复

2,101 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hello @kundan,

I hope you are doing well.

Please follow the below-given links thoroughly, It will help you understand the board's functioning.
https://www.myirtech.com/list.asp?id=690

Please find the product guide below.
https://www.myirtech.com/soft.asp?id=999

For more details on NXP i.MX8M mini MPU
Datasheet -> https://www.nxp.com/docs/en/data-sheet/IMX8MMCEC.pdf
Reference manual -> https://www.nxp.com/webapp/Download?colCode=IMX8MMRM

Please refer to the below link to toggle Gpio.
https://community.nxp.com/t5/i-MX-Processors/How-to-toggle-GPIO-in-user-space-in-iMx8-M-mini/m-p/108...

Please also find the knowledge base link given below for more details on toggling Gpio.
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Toggle-pin-on-i-MX-8M-Mini-Applications-...

I hope it helps!

Thanks & Regards,
Sanket Parekh

0 项奖励
回复