BeagleBone Black GPIO problem

Hell everybody,
I’ve got problem with driving GPIO pin P9_30 with BeagleBone Black, it is described as gpio3[16]. When I run my code, i don’t have any effect. Can anybody tell me what can be wrong?
main.c:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include “regs.h”
typedef uint32_t u32_t;
int main(void)
{
volatile u32_t *reg = NULL;
volatile u32_t *gpio3 = NULL;
volatile u32_t *pin = NULL;
volatile u32_t *set = NULL;
volatile u32_t *clear = NULL;
volatile u32_t *oe = NULL;
int fd = open("/dev/mem", O_RDWR | O_SYNC);
if(-1 != fd)
{
printf(“Opening file /dev/mem succeeded!\n”);
reg = mmap(NULL, CONTROL_MODULE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, CONTROL_MODULE_START);
if(MAP_FAILED != reg)
{
printf(“Mapping CONTROL MODULE succeeded!\nAddress: %p, Size: %d\n”, reg, CONTROL_MODULE_SIZE);
pin = reg + GPIO3_16;
*pin &= ~(1 << 6 | 1 << 5 | 1 << 3); // Fast rate, receiver disabled, pull-up enabled
*pin |= (1 << 4 | 1 << 2 | 1 << 1 | 1 << 0); // Pull-up selected, gpio3[16] enabled
printf(“Pin: 0x%X\n”, *pin);
gpio3 = mmap(NULL, GPIO3_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIO3_START);
if(MAP_FAILED != gpio3)
{
printf(“Mapping GPIO3 succeeded!\nAddress: %p, Size: %d\n”, gpio3, GPIO3_SIZE);
set = gpio3 + GPIO_SETDATAOUT;
clear = gpio3 + GPIO_CLEARDATAOUT;
oe = gpio3 + GPIO_OE;// enabling pin as output
*oe &= ~(1 << 16);
printf(“GPIO3_OE: 0x%X\n”, *oe);
*set = (1 << 16);//setting 1 to output
}
else
{
printf(“Mapping GPIO3 failed!\n”);
}
}
else
{
printf(“Mapping CONTROL MODULE failed!\n”);
}
}
else
{
printf(“Opening file /dev/mem failed!\n”);
}
return EXIT_SUCCESS;
}

regs.h:

Hi,

have you tried to check that your port is configured in MODE7 and in the correct Direction.

You can check with a cat on this file : /sys/kernel/debug/pinctrl/44e10800.pinmux/pins + a grep with 0x196, wich is the offset of P9-30 if I don’t make mistake. You should obtain a mux code of 0000037 or 00007 for example.

have a read at this page http://derekmolloy.ie/gpios-on-the-beaglebone-black-using-device-tree-overlays/

Device tree are very very convenient and not hard to understand.

Hope it helps.
nicolas