Second I2C address not responding


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198

    Default Second I2C address not responding

    Some time ago I bought several big, beautiful, single character LCDs. These things are 1.5" tall and just scream, "Look at me I'm cool!" I ordered up some backer-boards, populated them with PCF8574 port expanders and my gorgeous new chips, bread boarded several and had this really nice display all working. Oh, it was a thing of beauty! Then, the economy took a turn, job... etcetera.

    Long story short(er)... Life is good again and my attention has returned.

    I wrote a short, simple program because, well... I just wanted to see them work you know? I can't be the only one here that gets a little "goosebumpy" when intellect, dexterity, and technology all come together.

    Alas... no joy.

    I mean, technically, it works. Either digit works perfectly alone - in either position, but no amount of wishing will inspire the second address to respond. I am clearly missing something, but no amount of searching the forum, the internet, or the manual reveals an answer. I feel as though there needs to be something between the two writes - a stop, start, reset, a well enunciated "abracadabra"... something. I2CSTOP causes an error and no amount of pause resolves the issue. I've tried using a variable as the address, reversing the 2 statements... I don't know what else to try.

    Please take a look and explain what I'm missing?

    Code:
    #CONFIG
       __config _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF 
       __config _CONFIG2, _FCMEN_OFF & _IESO_OFF  
    #ENDCONFIG
    
    OSCCON = %01110000      'SET OSC OPTIONS
    DEFINE OSC 8 
    ANSEL = %00000011       'SET ANALOG TO DIGITAL
    TRISA = %00000000       'SET PORTS OUTPUT
    TRISB = %00000000
    
    DEFINE DEBUG_REG PORTB  'SERIAL OUT
    DEFINE DEBUG_BIT 5
    DEFINE DEBUG_BAUD 2400
    DEFINE DEBUG_MODE 0
    
    SDA VAR PORTB.1
    SCL VAR PORTB.4
    OUTP VAR BYTE
    LP VAR BYTE
    
    mainloop:
      FOR LP=0 TO 9
        READ LP, OUTP
        I2CWRITE SDA, SCL, $7C, OUTP	'WRITE 1's
        I2CWRITE SDA, SCL, $70, OUTP	'WRITE 10's 
        PAUSE 250
      NEXT LP	
    Goto mainloop                           'VIRTUAL END
    
    DATA 63, 6, 91, 79, 102, 109, 124, 7, 127, 103   'DEFINE DIGITS 0 - 9
    
    End
    I'm running it on a 16F88, internal 8M crystal, PBPX 3.0.4.4 and MCS 5.0.0.0

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    Something like:
    Code:
    ' test every location
    
    bruteforce var byte
    tencounter var byte
    howeverlongittakestoseethedisplaywrittenlive var word
    
        tencounter = 0
        FOR bruteforce = $00 TO $FF
        
        READ tencounter, OUTP
        I2CWRITE SDA, SCL, bruteforce, OUTP
     
        tencounter = tencounter + 1
        IF tencounter > 9 THEN
        tencounter = 0
        ENDIF
    
        PAUSE howeverlongittakestobeabletoseethedisplaywrittenlive
        NEXT bruteforce

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    Except that I fell for your mistake, and that's not how I2CWRITE works:

    I2CWRITE DataPin,ClockPin,Control,{Address,}[valvue{,Value...}]{,Label}

    ie.
    Code:
    I2CWRITE PORTC.4,PORTC.3,$ao,0,[STR a\8]
    I think you set the command to look for another I2C device on the bus rather than incremented the address index for the same device.

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    PAUSE 10 for the first write to complete because you used two I2CWRITE commands.
    (page 86).

  5. #5
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    It may be that I have not been clear or perhaps I do not understand your comment. There are two devices, one address $70, one $7C (ones digit and tens digit) on the same bus. I have several of the modules and have tried several different addresses... always the first executes (and displays) perfectly; the other never. Do you suggest that there is some parameter missing from the I2CWRITE statement?

    I tried adding ,[$00] in the case another tick was required to complete the "ACK", but no... error. In fact, everything I tried there failed. I thought I understood the syntax, but now I doubt.

  6. #6
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    I added a PAUSE 250 between... and no. Still no joy.

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    I didn't understand you were talking to two different devices.
    I thought it was supposed to be writing the least significant digit to the right of the display,
    and then the tens digit in the position to the left, on the same display.

    The I2CWRITE still looks incomplete:

    Code:
    I2CWRITE SDA,SDL,I2CDEVICESELECT,ADDRESSONDEVICE,DATA
    Last edited by Art; - 16th October 2013 at 14:46.

  8. #8
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    I was so impatient to try the suggestions made that I took the rest of the day off.

    Below is the modified code. I added another digit in hopes that the change might reveal the problem...

    Code:
    #CONFIG
       __config _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF 
       __config _CONFIG2, _FCMEN_OFF & _IESO_OFF  
    #ENDCONFIG
    
    OSCCON = %01110000      'SET OSC OPTIONS
    DEFINE OSC 8 
    ANSEL = %00000011       'SET ANALOG TO DIGITAL
    TRISA = %00000000       'SET PORTS OUTPUT
    TRISB = %00000000
    
    SDA VAR PORTB.1
    SCL VAR PORTB.4
    OUTP VAR BYTE
    LP VAR BYTE
    CHP100 VAR BYTE
    CHP010 VAR BYTE
    CHP001 VAR BYTE
    CHP100 = $74
    CHP010 = $72
    CHP001 = $78
    mainloop:
      FOR LP = 0 TO 9
        READ LP, OUTP
        I2CWRITE SDA, SCL, CHP001, CHP001, OUTP	'WRITE 1's
        PAUSE 250
        I2CWRITE SDA, SCL, CHP010, CHP010, OUTP	'WRITE 10's 
        PAUSE 250
        I2CWRITE SDA, SCL, CHP100, CHP100, OUTP	'WRITE 100's 
        PAUSE 250
      NEXT LP	
    Goto mainloop                           'LOGICAL END
    
    DATA 63, 6, 91, 79, 102, 109, 124, 7, 127, 103  
    End

    I think there is some progress in that now, at least, each digit will work independently. Applying power with all three modules plugged in, one (random) will work. Pulling the functioning digit, one of the others begins to cycle. Regardless of which digit I remove, one will always work; the others do not. It doesn't matter which spot they occupy - as long as they have a valid address.

    In addition, I tried changing the value of the I2C resistors: 3K3, 4K7, 10K0 - no change in function. The circuit is run from adequate supply and is well filtered...

    I still don't understand the "control" byte well, but RTFM indicates the class should match the fixed part of the address (MSBs) and the LSB should be zero; the addresses satisfy those requirements and beyond that I don't understand well enough to make an intelligent correction.

  9. #9
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    Sorry... double post

  10. #10
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    Do you have pullup resistors on each module? If so you should remove them otherwise you parallel them, and if the pullup value on the I2C bus become too low hardy it will work. A recommended value for bus pullup is 4.7K to 10K.

    Cheers

    Al.
    Last edited by aratti; - 16th October 2013 at 23:52.
    All progress began with an idea

  11. #11
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Second I2C address not responding

    Currently have 4K7s only. Doubled checked to be sure.

Similar Threads

  1. Replies: 2
    Last Post: - 27th August 2013, 22:07
  2. How to find I2C Slave address of PIC24FJ256GA110?
    By sharath12 in forum Off Topic
    Replies: 2
    Last Post: - 19th March 2012, 14:21
  3. PORTC.4 and C.5 not responding to inputs.
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 21:41
  4. 4 bit address decoding I2C chip
    By ecoli-557 in forum General
    Replies: 3
    Last Post: - 10th June 2008, 17:26
  5. Pic 18f252 not responding
    By gringo332 in forum General
    Replies: 5
    Last Post: - 22nd March 2007, 21:21

Members who have read this thread : 0

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