Lorenzo, this works fine, its nice to have some inputs now!

You just have to make sure in your code to write (255 or 0xFF) to the
port prior to a read to turn off the LEDS briefly if you intend to
piggyback the inputs as it will read in their status which could be
masking your switch value.

Other than that a further mod could be to have the IC generate an
interrupt rather than poll it, however the latter seems to not really
use much in the way of system resources. 

Not really sure what the code would look like to get an interrupt from
it, but sure some will crop up.

Hope this is of use to the forum.

Andrew


On Thu, 2006-10-12 at 15:04 +0200, Lorenzo Lutti wrote:
> From: "Andrew Armstrong" <[EMAIL PROTECTED]>
> 
> > I might look into that, but as I intend to use the pins
> > the LEDS occupy
> > as inputs, so will come up with some sort of design,
> > possibly one that
> > leaves the LEDS in place.
> 
> It should be possible. By reading the PCF8574A datasheet:
> 
> http://focus.ti.com/lit/ds/symlink/pcf8574a.pdf
> 
> It looks like the pin direction is automatically switched when you
> read/write on the I2C bus. Something like this should work:
> 
> 1) Solder your pushbutton between the LED cathode and GND (it won't make any
> short circuit because the PCF outputs are open collector);
> 2) Write a byte to the controller to set up the LED;
> 3) Read a byte from the controller to read the pushbutton status. When the
> button isn't pushed you will probably read a '1' (no current is flowing, so
> the LED voltage dropout should be small); when the button is pushed you will
> read a '0';
> 4) Repeat the step 2 to refresh the LED status (or the LEDs will stay turned
> off).
> 
> The only drwaback is that when you push the button, this will turn on the
> LED.
> 
> Anyway, before doing anything look at the datasheet and the page 27 of the
> EVM schematics. I won't be responsible if you burn the EVM. ;)
> 
> Cheers, Lorenzo
> 
> _______________________________________________
> Davinci-linux-open-source mailing list
> Davinci-linux-open-source@linux.davincidsp.com
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

_______________________________________________
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to