This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

which GPIO pin is i have to use for testing purpose on OMAPL138 board

Other Parts Discussed in Thread: OMAPL138

Hi,

i am planing to test with some OMAPL138 GPIO pins making it as HIGH or LOW  using LINUX in user space.

currently i am using LogicPD OMAPL138 experimenter board, and in that board i am using GPIO6[14] pin as a output its 18 pin on J3 connector, but  i am not getting output.

actually i am going with  below source code is it correct what am doing ? suggest  me any other example ??

 #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;   // Setting register
    volatile unsigned int *REVid;   // Revision ID register
    
    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);
    REVid = (unsigned int *)(gpio + 0x00); // Output reg offset address     
    printf("REVid value = %x \n", *REVid); //Print the REVid value

    PDR = (unsigned int *)(gpio + 0x10); // Output reg offset address bank 0
        PDATA = (unsigned int *)(gpio + 0x88); //Direction Reg offset address
    //PSET = (unsigned int *)(gpio + 0x8C); //setting 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
        //printf("GPIO pin LOW \n");
        //sleep(1);
    }
         
       return 0;
   }