i2c PBP questions


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Location
    Toronto
    Posts
    11


    Did you find this post helpful? Yes | No

    Default i2C and EEPROM

    Thanks Steve:

    I will change ADDR to be "Word". Is it acceptable to just say $07 as the address I want to write to?

    The data sheet for the EEPROM states that it is expecting the Address High after it acknowledges the Start condition.

    It is written as "high-order byte of the word address and will be written into the Address Pointer" Is the address pointer the location that I intend to write to? It then says that the next byte (2nd half of address word) is the least significant address byte. It does not say what this represents.

    The EEPROM has memory addressing from $0000 - $FFFF. Should my $07 as a target address go in as $0700 and then 0000 as the second half of the word?

    Confused,

    Tim

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


    Did you find this post helpful? Yes | No

    Default

    When you write ADDR=$07 or ADDR=$7, it store $0007 to the word variable in one shot...If you prefer in the MSB and LSB. have Look to your EEPROM datasheet...
    http://ww1.microchip.com/downloads/e...doc/21754E.pdf

    Look Figure 6-1. What happen if your address variable is a byte? Yes it miss the LowByte of the address. Using a word sized variable, nothing is missing.

    Nothing else to worry about, I2CREAD/WRITE will do the job for you.

    P.S. : Welcome on the forum Yet another Canadian Woohoo !!!
    Steve

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

  3. #3
    Join Date
    Jan 2007
    Location
    Toronto
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Steve:

    Thanks for the response. Happy to strengthen the Canadian contingent

    I am sitting here watching the program run on the ICD. I wish they went faster.

    I will confirm that the address stuff is exactly as you said. I watched 8 0s get fed before it put in my address and I am now watching shift my address across.

    From what I can see, everything is working properly.

    When I let it run, I am expecting to see the number contained in the [] brackets on the write statement returned in my byte i2c_Data which is in the [] brackets in my read statement.

    If this correct?

    The read statement does not hit the "Fail" after the [] so that would imply that the program is "running".

    Tim

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


    Did you find this post helpful? Yes | No

    Default

    Running or at least it says that there's something on the I2C lines.

    If you really want to know if it's working, you could still write to the EEPROM, then read back the data, if both are the same... it confirm it's working.. just fine.
    Steve

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

  5. #5
    Join Date
    Jan 2007
    Location
    Toronto
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Steve:

    Well that is my big question in my previous response. If this was doing what it is supposed to be doing, would I not see the result in my i2c_Data variable?

    ADDR var word
    ADDR = $07
    PAUSE 10
    I2CWRITE PORTC.4,PORTC.3,$A0,ADDR,[1]
    PAUSE 10

    I2CREAD PORTC.4,PORTC.3,$A0,ADDR,[i2c_Data],Fail
    PAUSE 10

    GOTO MAIN

    Fail:
    PORTC.5 = 1
    GOTO MAIN

    I would expect i2c_Data to contain "1"

    It does not.

    Am I giving everything enough time?

    Thanks

    Tim

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


    Did you find this post helpful? Yes | No

    Default

    Try this one, it's working here
    Code:
    define LOADER_USED 1
    disable debug
    Data_READ   var byte
    Data_Write  var byte
    Bad         var bit
    ADDR        var word
    SDA         var PORTC.4
    SCL         var PORTC.3
    Control     con $A0
    
    Bad = 0
    
    Start:
        For addr=0 to $FFFF
            
            data_write=addr.lowbyte
            bad = 0
            I2CWRITE sda,scl,control,ADDR,[data_write]
            PAUSE 10 
    
            I2CREAD sda,scl,control,ADDR,[Data_read]
            enable debug
                data_read=data_read ' refresh ICD display
            disable debug
            if data_read != data_write then bad=bad +1
    
            next
        GOTO Start
    Last edited by mister_e; - 2nd February 2007 at 03:09.
    Steve

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

  7. #7
    Join Date
    Jan 2007
    Location
    Toronto
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Steve:

    Thanks for posting the code. How long should this take to complete? I can see that it is cycling through addresses 0 to $FFFF. I put in a line between the next and GOTO Start to light up one of the status LEDs I have on the board.

    It is not lighting up. In the watch window, Data_READ is blank. When I pause the program, I am in the library PBPPIC14.LIB stuck in the PAUSE routine waiting for the carry bit to be cleared. This bit does not get cleared.

    I just thought of something. I have no includes in my program as I normally did with assembler. I am just starting out with PBP.

    Am I perhaps not adding some includes that I need?

    I didn't see a list in the manual anywhere of any special requirements that have to be in the code. I don't have a device include either.

    Please advise


    Thanks

    Tim

Similar Threads

  1. explanation on I2C command (PBP)
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th May 2014, 05:30
  2. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  5. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27

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