problems working with 24C512


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    thanks for your help

    mat jensson you have raised a nice point here. I have tried almost every possibility in my coding as well as in my connections, but its not working at all. Please explain me your idea,
    i mean what do u mean by marking the read bit? and how can i specify two addresses, can u explain me a bit.

    One more thing that i want to share with u all. I get different numbers as output when i connect SDA SCL on different ports.


    when i have

    SDA = portB.1
    SCL= portB.0
    output= 2

    SDA = portD.1
    SCL= portD.0
    output= 2

    SDA = portC.1
    SCL= portC.0
    output= 8

    I just couldnt get it.



    Regards,

    Shaiq Bashir
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Make sure you have A0,A1,A2 on your EEPROM at ground.

    Make these few changes to your existing code.

    CNTRL VAR BYTE ' added for control byte
    CNTRL = %10100000 ' value of control byte

    EWrite:
    I2CWRITE SDA,SCL,CNTRL,Addr,[E_ByteOut] ' Write out the byte
    Pause 10 ' Delay 10ms after each write
    Return

    ERead:
    I2CREAD SDA,SCL,CNTRL,Addr,[E_ByteIn] ' Read in the byte
    Return

    Does this work?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    For the really last time, i'm still sure your SDA/SCL are reverted and/or you don't have the right Pull-Up resistors on SDA & SCL, and i also endorse the A<2:0> setting.

    OK why i stick to it ?

    1. Because i already used something like that in one of my Radio Decode Dongle to confirm the end-user haven't swap the SDA/SCL line when reading in circuit the target I2C EEprom inside the radio.

    2. Let's say i use a at24c1024 here with the following...
    Code:
            CONT    CON %10100000
            ADDR    VAR WORD
            ByteA   VAR BYTE
            
            SDA     var PORTC.4
            SCL     var PORTC.3        
            PAUSE   500
            
    Start:
            for addr = 0 to 10
                    ByteA=ADDR.LOWBYTE
                    I2CWRITE SDA,SCL,CONT,ADDR,[ByteA]
                    PAUSE 20
                    NEXT
                    
            FOR ADDR=0 TO 10
                    I2CREAD SDA,SCL,CONT,ADDR,[ByteA]
                    HSEROUT ["ADDR=", DEC ADDR,_
                             "   ByteA=", DEC ByteA,13,10]
                    NEXT
    I got the expected..
    Code:
    ADDR=0   ByteA=0
    ADDR=1   ByteA=1
    ADDR=2   ByteA=2
    ADDR=3   ByteA=3
    ADDR=4   ByteA=4
    ADDR=5   ByteA=5
    ADDR=6   ByteA=6
    ADDR=7   ByteA=7
    ADDR=8   ByteA=8
    ADDR=9   ByteA=9
    ADDR=10   ByteA=10
    But now if in my code i swap the SDA, SCL definition to...
    Code:
            SDA     var PORTC.3
            SCL     var PORTC.4
    i got...
    Code:
    ADDR=0   ByteA=8
    ADDR=1   ByteA=8
    ADDR=2   ByteA=8
    ADDR=3   ByteA=8
    ADDR=4   ByteA=8
    ADDR=5   ByteA=8
    ADDR=6   ByteA=8
    ADDR=7   ByteA=8
    ADDR=8   ByteA=8
    ADDR=9   ByteA=8
    ADDR=10   ByteA=8
    Amazing how close to your problem it is huh?

    Let's do it much funky now... let's totally remove the EEPROM from the circuit. With the pull-up installed i still have all those 8, without pull-up i got all 0.

    Now, with the right code, but the EEPROM have the wrong A<2:0> setting...
    i got all 16, reverted... all 8.

    Enjoy!
    Last edited by mister_e; - 29th May 2008 at 05:30.
    Steve

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

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Let this be the schematic for reference.


    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2625&d=1212050571" >
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. PIC30f4012 Problems
    By Insane in forum mel PIC BASIC
    Replies: 4
    Last Post: - 18th June 2010, 07:16
  2. Blink.Bas on 18f45k20 Newbie seeks working example.
    By DiscoEd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 03:36
  3. lcd menu problems
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd April 2009, 19:00
  4. 2 PWM in 16F690 problems
    By ciendavila in forum mel PIC BASIC
    Replies: 9
    Last Post: - 27th April 2008, 09:03
  5. Why is this so hard? HSEROUT problems.
    By groston in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th November 2006, 13:01

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