Skip to contentSkip to conversation

Peculiar Behaviour of the GPIO Program

DISCUSSION Azhar Mr. 3 participants 3 messages Nov 23, 2007 – Nov 27, 2007

lore
Share & tools
lore

Azhar Mr.

author
#0 lore raw

Dear all,

I am working on OMAP5912 OSK.

I am trying to write a simple GPIO Program to write a value ‘1’ to a particular free GPIO Pin. For that I had written a program led_glow.c given below.

/* define any of the valid GPIO pins as LED_GPIO */ #define LED_GPIO 18

/* Defines the value written to the pin defined as LED_GPIO */

  #define LED_STATUS 1
   
  MODULE_LICENSE("Dual BSD/GPL");
   
   
  int init_module(void)
  {
        /* requesting for LED_GPIO */
        if(omap_request_gpio(LED_GPIO)<0)
        {
   printk("[ERROR]: Failed in allocating the requested GPIO Pin \n");
              return -1;
        }
        /* setting LED_GPIO as output pin */
   
       omap_set_gpio_direction(LED_GPIO,0);
   
        /* writing to LED_GPIO the value of LED_STATUS */
   
        omap_set_gpio_dataout(LED_GPIO,LED_STATUS);
   
        /* printing the value of LED_GPIO pin */
  printk("value of pin # %d = %d\n",LED_GPIO,omap_get_gpio_datain(LED_GPIO));
        return 0;

}

  void cleanup_module(void)
  {
        omap_free_gpio(LED_GPIO);     
  printk("[SUCCESS]: LED_GLOW Module unregistered successfull.\n");
  }

I included our led_glow.c as a module in the Linux-2.6.22/drivers/leds directory .

Then using arm-linux-gcc compiler, I compiled the led_glow.c code to obtain led_glow.ko

Then using the insmod I inserted the module led_glow.ko in the OSK5912 Environment.

I tested the module with various free GPIO-Pins of Expansion connector 'C'

For some GPIO pins it is able to write the value '1' and for some pins it is unable to write '1'

Sh-3.00# value of pin #15 = 1
Sh-3.00# value of pin #16 = 1
Sh-3.00# value of pin #17= 0
Sh-3.00# value of pin #20 = 0

I tested all the free GPIO pins of EXPANSION CONEECTOR C, irrespective of the printed value at the GPIO Pins at all the GPIO Pins I can observe only '0' value in the C.R.O. I could not get any response in the C.R.O

I don’t understand this peculiar behavior of my GPIO-CODE.

Please Help

With Regards

Azhar

---------------------------------
Bring your gang together - do your thing. Start your group.

#1 lore raw

The GPIO driver does not automatically do the required pin muxing for you. It is possible that the pin you are looking at is muxed with other signals. Look at the OMAP TRM, and set the Pin Mux register correctly. -Prasad

-----Original Message-----
From: linux-omap-open-source-bounces+kherur=nextwave.com@linux.omap.com [mailto:[email protected] m] On Behalf Of Azhar Mr.
Sent: Thursday, November 22, 2007 10:35 PM
To: [email protected]
Subject: Peculiar Behaviour of the GPIO Program

Dear all,

I am working on OMAP5912 OSK.

I am trying to write a simple GPIO Program to write a value '1' to a
particular free GPIO Pin. For that I had written a program led_glow.c given below.

/* define any of the valid GPIO pins as LED_GPIO */ #define LED_GPIO 18

/* Defines the value written to the pin defined as LED_GPIO */

  #define LED_STATUS 1
   
  MODULE_LICENSE("Dual BSD/GPL");
   
   
  int init_module(void)
  {
        /* requesting for LED_GPIO */
        if(omap_request_gpio(LED_GPIO)<0)
        {
   printk("[ERROR]: Failed in allocating the requested GPIO Pin \n");
              return -1;
        }
        /* setting LED_GPIO as output pin */
   
       omap_set_gpio_direction(LED_GPIO,0);
   
        /* writing to LED_GPIO the value of LED_STATUS */
   
        omap_set_gpio_dataout(LED_GPIO,LED_STATUS);
   
        /* printing the value of LED_GPIO pin */

printk("value of pin # %d =
%d\n",LED_GPIO,omap_get_gpio_datain(LED_GPIO));

        return 0;

}

  void cleanup_module(void)
  {
        omap_free_gpio(LED_GPIO);     
  printk("[SUCCESS]: LED_GLOW Module unregistered successfull.\n");
  }

I included our led_glow.c as a module in the Linux-2.6.22/drivers/leds
directory .

Then using arm-linux-gcc compiler, I compiled the led_glow.c code to
obtain led_glow.ko

Then using the insmod I inserted the module led_glow.ko in the OSK5912 Environment.

I tested the module with various free GPIO-Pins of Expansion connector
'C'

For some GPIO pins it is able to write the value '1' and for some pins
it is unable to write '1'

Sh-3.00# value of pin #15 = 1
Sh-3.00# value of pin #16 = 1
Sh-3.00# value of pin #17= 0
Sh-3.00# value of pin #20 = 0

I tested all the free GPIO pins of EXPANSION CONEECTOR C, irrespective
of the printed value at the GPIO Pins at all the GPIO Pins I can observe only '0' value in the C.R.O. I could not get any response in the C.R.O

I don't understand this peculiar behavior of my GPIO-CODE.

Please Help

With Regards

Azhar

---------------------------------
Bring your gang together - do your thing. Start your group.
_______________________________________________
Linux-omap-open-source mailing list [email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

#2 lore raw
Quoted 4 lines · ext Krishna Prasad Herur

The GPIO driver does not automatically do the required pin muxing for you. It is possible that the pin you are looking at is muxed with other signals. Look at the OMAP TRM, and set the Pin Mux register correctly. -Prasad

Pullup/pulldown settings might require some adjustment too.

Quoted 103 lines

-----Original Message-----
From: linux-omap-open-source-bounces+kherur=nextwave.com@linux.omap.com [mailto:[email protected] m] On Behalf Of Azhar Mr.
Sent: Thursday, November 22, 2007 10:35 PM
To: [email protected]
Subject: Peculiar Behaviour of the GPIO Program

Dear all,

I am working on OMAP5912 OSK.

I am trying to write a simple GPIO Program to write a value '1' to a
particular free GPIO Pin. For that I had written a program led_glow.c given below.

/* define any of the valid GPIO pins as LED_GPIO */ #define LED_GPIO 18

/* Defines the value written to the pin defined as LED_GPIO */

  #define LED_STATUS 1
   
  MODULE_LICENSE("Dual BSD/GPL");
   
   
  int init_module(void)
  {
        /* requesting for LED_GPIO */
        if(omap_request_gpio(LED_GPIO)<0)
        {
   printk("[ERROR]: Failed in allocating the requested GPIO Pin \n");
              return -1;
        }
        /* setting LED_GPIO as output pin */
   
       omap_set_gpio_direction(LED_GPIO,0);
   
        /* writing to LED_GPIO the value of LED_STATUS */
   
        omap_set_gpio_dataout(LED_GPIO,LED_STATUS);
   
        /* printing the value of LED_GPIO pin */

printk("value of pin # %d =

%d\n",LED_GPIO,omap_get_gpio_datain(LED_GPIO));
   
        return 0;

}

  void cleanup_module(void)
  {
        omap_free_gpio(LED_GPIO);     
  printk("[SUCCESS]: LED_GLOW Module unregistered successfull.\n");
  }

I included our led_glow.c as a module in the Linux-2.6.22/drivers/leds
directory .

Then using arm-linux-gcc compiler, I compiled the led_glow.c code to
obtain led_glow.ko

Then using the insmod I inserted the module led_glow.ko in the OSK5912 Environment.

I tested the module with various free GPIO-Pins of Expansion connector
'C'

For some GPIO pins it is able to write the value '1' and for some pins
it is unable to write '1'

Sh-3.00# value of pin #15 = 1
Sh-3.00# value of pin #16 = 1
Sh-3.00# value of pin #17= 0
Sh-3.00# value of pin #20 = 0

I tested all the free GPIO pins of EXPANSION CONEECTOR C, irrespective
of the printed value at the GPIO Pins at all the GPIO Pins I can observe only '0' value in the C.R.O. I could not get any response in the C.R.O

I don't understand this peculiar behavior of my GPIO-CODE.

Please Help

With Regards

Azhar

---------------------------------
Bring your gang together - do your thing. Start your group.
_______________________________________________
Linux-omap-open-source mailing list [email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

Signature · 4 lines
Cheers, Igor

Igor Stoppa <[email protected]>
(Nokia Multimedia - CP - OSSO / Helsinki, Finland)