1

After enabling the GPIO device support in kernel device driver (Kernel verion 3.10.92) I wanted to read the value of an input pin of my GPIO expander through GPIO sysfs. After exporting and setting the direction as in, on reading, the value is always given as 0 even after the event is happening which will change the pin value as 1. While the output direction is working fine i.e. I am able to glow a LED by altering the value as 0 or 1.

Base address for my GPIO expander in GPIO sysfs is 184. So, to read the pin number 22 i.e. pin number 206 according to GPIO sysfs, the commands I gave in kernel are

echo 206  > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio206/direction
cat /sys/class/gpio/gpio206/value # always gives the value as 0

I am using PCA9505 GPIO expander (40 I/O pins) which is connected to MPC8308 microprocessor and controlled through mpc I2C bus.

phuclv
  • 37,963
  • 15
  • 156
  • 475
M P Singh
  • 11
  • 3
  • Well, first, when you push your button/switch, does the GPIO state physically change when you check it with a meter or scope? – Martin James Nov 17 '15 at 08:04
  • Try to verify via measurement that this pn is on high level. Are other pins working as expected? – schorsch_76 Nov 17 '15 at 08:26
  • @MartinJames i checked the pin voltage of the gpio expander through multimeter which was showing 0 and 1 as per the event. – M P Singh Nov 17 '15 at 08:52
  • @schorsch_76 i tried to read other input pins also, but in vain. They all are giving same value as 0 – M P Singh Nov 17 '15 at 08:54
  • Multimeter was showing 1? 1 what, 1V? Quick google search says PCA9505 voltage levels are 2.3V to 5.5V. Make sure you're in that range on GPIO side and also I2C side (your I2C host might have 1.8V interface). – domen Nov 17 '15 at 09:15
  • The 1 and 0 are not voltages, I mean logical 1 and 0, which in my case its 3.3V and 0V in multimeter.. – M P Singh Nov 17 '15 at 09:47

0 Answers0