Problem to read a PCF 8574


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13

    Unhappy Problem to read a PCF 8574

    Hi everybody!

    I have a problem with PCF8574. I would have the necessity to read the state of 8 connected buttons to a PCF8574 and subsequently to visualize the sequence read on a display LCD of it. Have I written this firmware but doesn't it work, where am I being wrong?

    Thanks everybody!



    @ DEVICE HS_OSC
    @ DEVICE pic16F877A
    define OSC 20
    ADCON1 = 7

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 2

    Symbol SDA = PORTC.0
    SYMBOL SCL = PORTC.1
    symbol INT = PORTC.2

    DATAPCF VAR BYTE
    clear

    LCDOUT $fe,1,"Test read PCF: "

    Loop:
    if INT = 0 then ReadPCF
    goto Loop

    ReadPCF:
    I2Cread SDA,SCL,%01110001,DATAPCF
    LCDOUT $FE,$C0,"Data: ",bin dataPCF," "
    PAUSE 1000
    goto Loop

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The PCF8574 is a 100khz device.

    At 20mhz, you'll need to add...
    Code:
    DEFINE I2C_SLOW 1
    <BR>
    DT

  3. #3
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The PCF8574 is a 100khz device.

    At 20mhz, you'll need to add...
    Code:
    DEFINE I2C_SLOW 1
    <BR>

    Hi Darrel! Thanks you very much for your fast answer! Have tried to add the command that you have signalled me, but have not improved the situation! Have tried to put DEFINE OSC 4 but the result is not improved! is it possible that the error is in the address ( %01110001) of the device?

    Thanks very much

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    I2Cread SDA,SCL,%01110001,[DATAPCF]
    depending if you're using an A version the control byte may differ.

    Assuming your 4.7K pull-up (or lower) are on the I2C BUS, and you also have some on the PCF i/o... it should work.

    if i remind correctly, prior to be able to read read from this device, all i/o have to be at high level.

    i know i forgot something...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Code:
    I2Cread SDA,SCL,%01110001,[DATAPCF]
    depending if you're using an A version the control byte may differ.

    Assuming your 4.7K pull-up (or lower) are on the I2C BUS, and you also have some on the PCF i/o... it should work.

    if i remind correctly, prior to be able to read read from this device, all i/o have to be at high level.

    i know i forgot something...

    Dear Steve!
    Thank you very much! I have resolved my problems! The problem was in the resistances from 10k that had inserted in the bus I2C, that didn't give some problem in writing but they didn't allow the reading! Have replaced her with two resistances 4K7 and the problem has been resolved!

    Thank you very much!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Bienvenue et bonne chance!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. write -read problem?
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th August 2009, 13:06
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. EEPROM Read problem
    By Christos_K in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th June 2005, 17:10
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts