Hi
I am using GPIO6[14] as a output port pin on OMAPL138, i want to set the port pin as a output, and i am checking with R31 as a output, but its not working.
i am referring with base board schematic as well as SOM board schematic. i am using J3 connection 18 pin as a gpio output, and i am taking R31 as a output with CRO, i am not getting any high on that line. how to check that GPIO is working or not or pin is high/lowt. in user space applications.
This is my code to test GPIO6[14] pin, R31 or TP6 as a output as per omapl138 schematic.
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
//#define GPIO_BASE 0x80840000
#define GPIO_BASE 0x01E26000 // Base address of GPIO OMAPL138
/* GPIO memory mapped registers */
volatile unsigned int *PDR; // Direction register
volatile unsigned int *PDATA; // Port output DATA
volatile unsigned int *PSET;
int main (void)
{
unsigned char *gpio;
int fd;
fd = open("/dev/mem", O_RDWR);
if (fd < 0)
{
perror("Failed to open /dev/mem");
return fd;
}
gpio = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_BASE);
// PEDR = (unsigned int *)(gpio + 0x20);
// PEDDR = (unsigned int *)(gpio + 0x24);
PDR = (unsigned int *)(gpio + 0x88); // Output reg offset address
PDATA = (unsigned int *)(gpio + 0x8C); //Direction Reg offset address
PSET = (unsigned int *)(gpio + 0x90); //Direction Reg offset address
printf("PDR address = %x PDATA address= %x \n", ( unsigned )PDR, ( unsigned )PDATA); //Print the register address
// *PDATA = 0x00004000; //Port6[14] direction as output
*PDR = 0x00000000; //Port6[14] direction as output
*PSET= 0xffffffff;
while(1)
{
*PDATA = 0xffffffff; //Port6[14]pin status as HIGH
printf("GPIO pin HIGH \n");
sleep(1);
*PDATA = 0x00000000; //Port6[14]pin status as LOW
sleep(1);
}
return 0;
}