Hi guys,
I’m trying to use the gpio using /dev/mem with PB2.
I could turn on and off the led on GPIO1_12 with:
devmem2 0x00601010 w 0x0000
devmem2 0x00601018 w 0x1000
devmem2 0x00601014 w 0x1000
and off
devmem2 0x0060101C w 0x1000
devmem2 0x00601014 w 0x0000
And in a C program like EBC Exercise 11b gpio via mmap - eLinux.org was working like a charm updating the memory address and registers.
But when I try to use the GPIO0_45 the board is simply hanging.
devmem2 0x0000600010 w 0x000000000000
devmem2 0x0000600018 w 0x200000000000
devmem2 0x0000600014 w s0x200000000000
Is there something I lost between the value to be writted to the register - I’m confused about the registers.
If I use the gpioset 1 45=1 and gpioset 1 45=0 the led is working fine - where I can find the source code for the gpioset ?
Thanks
gpioset would be using libgpiod. I’d strongly suggest you flipping to start using it as well.
The GPIO0_45 would also be in dataset 2 so the base address would be 00600038, not 00600010.
Hi @Daniel_Kulp
In my case it’s not possible to use the libgpiod.
Using /dev/mem, you first open the base address for the gpio 00600000 and then use the register offset - in this case the 0x10 is the GPIO_DIR01, so the address 0x00600010 you have all the direction for the pins(in/out).
Writting for instance - 0x0000 you set all pins as output. The register 0x18 is the GPIO_SET_DATA01 , writting 1 in the bit - in this case the 12 (8th bit in the register) will result in a high value at the P1.04 (GPIO1_12).
I know how it works… I use the memory locations to toggle GPIO’s from the PRU’s. GPIO_DIR01 is for banks 0 and 1 of GPIO0. Those are for GPIO number 0-31. GPIO 45 would be in bank 2. Thus, you need the memory locations for GPIO_DIR23.
Hi @Daniel_Kulp
thanks, I will try
thanks a lot.