Philips PCF 8591


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default Philips PCF 8591

    Has anyone successfully read a Philips 8591 using PBP? I can "talk" to virtually any other device I have come across, but this one has me stumped.

    Can someone tell me what I'm doing wrong? And yes, I have pull-ups on the SCL and SDA lines!

    Code is below.
    ---------------------------------------------------------------------

    PCF8591 CON %10010000

    SetupI2C:

    DevAddr = 0
    DevAddr = DevAddr << 1
    DevAddr = PCF8591 | DevAddr
    I2CWRITE PORTC.4,PORTC.5,DevAddr,$44,[0] ; Use internal clk, auto-increment mode
    RETURN

    ReadI2C:

    DevAddr = 0
    DevAddr = DevAddr << 1
    DevAddr = PCF8591 | DevAddr
    I2CREAD PORTC.4,PORTC.5,DevAddr,[PSByte1,PSByte2,PSByte3,PSByte4] ; Read all 4 channels

    RETURN
    Charles Linquist

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Charles,

    I was really waiting for one of the gurus to answer this as I am no expert in I2C but I think the problem is in the DevAddr setup. Did you try breaking this down into all of the separate elements? "DevAddr = PCF8591 | DevAddr" is a logical ORing of "PCF8591" and DevAddr when you should be addressing the address byte and the control byte separately. I have only used I2C for the DS1337 RTC and have tried it once with the 8574A chip. No problems. I do understand after looking at the datasheet that this is a little out of my league but the concept is basically the same.

    Also in the receive section, don't the PSbyte's have to start with PSbyte0 first? Your variables aren't listed so I don't know how you have them set up.

    HTH,

    BobK

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Has anyone successfully read a Philips 8591 using PBP? I can "talk" to virtually any other device I have come across, but this one has me stumped. Can someone tell me what I'm doing wrong? And yes, I have pull-ups on the SCL and SDA lines!

    Code is below.
    ---------------------------------------------------------------------

    PCF8591 CON %10010000

    SetupI2C:

    DevAddr = 0 : DevAddr = DevAddr << 1 : DevAddr = PCF8591 | DevAddr
    I2CWRITE PORTC.4,PORTC.5,DevAddr,$44,[0] ; Use internal clk, auto-increment mode
    RETURN

    ReadI2C:

    DevAddr = 0 : DevAddr = DevAddr << 1 : DevAddr = PCF8591 | DevAddr
    I2CREAD PORTC.4,PORTC.5,DevAddr,[PSByte1,PSByte2,PSByte3,PSByte4] ; Read all 4 channels

    RETURN
    I just read the datasheet. Check page 19, SCL freq. The PCF8591 is a 100khz device, not 400khz (or even 1mhz for that matter).
    You probably have to use:
    DEFINE I2C_SLOW 1
    in your code to slow it down a bit.

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    OK, a bit more explanation.

    I DO have the DEFINE I2C_SLOW 1 in my header,

    Also,
    The logical OR is to set the actual device address.
    The "identifier" address of the PCF 8591 is %1001xxxy,
    where "xxx" = the sub-address (as set by the 3 hardware
    addressing pins), and "y" is the Read/Write bit. I have to shift
    the sub-address (or hardware address) left with the << 1
    to align it properly.

    So, with my ORing statement, I'm actually sending

    %10010000

    (the chip has all 3 hardware address pins grounded)

    Then I'm sending $44, which is supposed to be the control byte,
    Then a data byte of "0", to tell it to start at channel "0"

    The datasheet says $44 is the command to put it in the "auto-
    increment" mode with "internal oscillator". After that, all you are supposed to have to do is read the chip.

    A READ is supposed to give me all 4 channels at once.

    I2CREAD PORTC.4,PORTC.5,DevAddr,[PSByte1,PSByte2,PSByte3,PSByte4]

    The chip doesn't care what I call the bytes.




    If any of this isn't correct, please tell me. Maybe that will help me
    solve my problem.
    Charles Linquist

  5. #5
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Charles,

    Isn't the "Write" DevAddr suppose to be different than the "Read" address with the LSB being a "0" for write operation and a "1" for a read operation?

    Thank you for the explanation of the ORing. I'm learning more here!

    BobK

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    PBP automatically changes bit0 in the string. It handles the differences between WRITE and READ.
    Charles Linquist

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    OK, a bit more explanation.

    I DO have the DEFINE I2C_SLOW 1 in my header,
    Ah...and I thought for sure I had it.
    But another idea hit me looking thru the code...
    You've got the R/W set to 0, should be a 1 for a read and 0 for a write.
    Maybe, maybe not. Seems like that's the way it is for the other eeprom's I use.

    I'm a bit late on the refresh button I'm thinking! You guys already got it...
    Last edited by skimask; - 28th March 2007 at 02:32. Reason: Day late dollar short!

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Check the PBP mqnual. PBP *AUTOMATICALLY* sets the LSbit to the
    correct value. That is, the I2CREAD instruction FORCES the bit to "1"
    and I2CWRITE FORCES it to "0". Try it in your code, and you will find
    that it works.
    Charles Linquist

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Check the PBP mqnual. PBP *AUTOMATICALLY* sets the LSbit to the
    correct value. That is, the I2CREAD instruction FORCES the bit to "1"
    and I2CWRITE FORCES it to "0". Try it in your code, and you will find
    that it works.
    I know. I was jumping back and forth while typing in my last post, checking the datasheet for the PCF, the manual, I2C spec's, etc. I should've hit refresh before submit!

  10. #10
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Have you tried the hold option

    Hi,

    Have you tried the DEFINE I2C_HOLD 1 in your prog ? Any difference using or not using it ?
    Regards

    Sougata

  11. #11
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi,

    Have you tried the DEFINE I2C_HOLD 1 in your prog ? Any difference using or not using it ?


    Yes, I tried that. No difference.
    Charles Linquist

  12. #12
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Any luck Charles ?

    Hi,

    There has been no update. Please do let us know if you succeed and how.
    Regards

    Sougata

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Hi, Charles

    Found a demo here ... :

    Listing 2
    ' Nuts & Volts "Stamp Applications" -- November, 2001

    ... may be it will help

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default Re: Philips PCF 8591

    Hi Charles (long time - no hear),

    Did you ever find the answer to this problem? I'm looking at using the chip, but not if there's unforseen gotchas.

    Thanks!
    Len

Similar Threads

  1. Philips FR951 Schema needed
    By fredje in forum Schematics
    Replies: 4
    Last Post: - 19th May 2010, 19:47
  2. Problem to read a PCF 8574
    By Darklakebridge7 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2007, 21:56
  3. Pcf 8583
    By srspinho in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2006, 19:41
  4. I2C compass - Philips KMZ51
    By barkerben in forum General
    Replies: 0
    Last Post: - 25th December 2005, 20:10

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