A help with Write/Read a I2C memory


Closed Thread
Results 1 to 26 of 26

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi, something like the following will work.
    Code:
            EEP1    con %10100000 ' First EEPROM A<2:0>=Gnd
            
            Addr    var word
            ByteA   var byte
            ByteB   var byte
            
            PAUSE 50
         
                addr=0
                BYTEA="A"
                byteb="B"
                I2CWRITE SDA,SCL,EEP1,ADDR,[bYTEA," TEXT1",BYTEB," TEXT2"]
                PAUSE 10
                
           FOR ADDR=0 TO 13
                I2Cread SDA,SCL,EEP1,ADDR,[bYTEA]     
                hserout [BYTEA]
                next
        
            @ GOTO $
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    in your first example, try to change to..
    Code:
    <font color="#000000">        @ __CONFIG _XT_OSC &amp; _WDT_ON &amp; _PWRTE_ON &amp; _BODEN_ON &amp; _LVP_OFF                  
            <font color="#000080">DEFINE </font>OSC 4
            <font color="#000080">INCLUDE </font>&quot;Modedefs.bas&quot;
            
            <font color="#000080">DEFINE </font>LCD_DREG PORTB
            <font color="#000080">DEFINE </font>LCD_DBIT 4
            <font color="#000080">DEFINE </font>LCD_RSREG PORTB
            <font color="#000080">DEFINE </font>LCD_RSBIT 3
            <font color="#000080">DEFINE </font>LCD_EREG PORTB
            <font color="#000080">DEFINE </font>LCD_EBIT 2
            
            SDA <font color="#000080">VAR </font>PORTC.4
            SCL <font color="#000080">VAR </font>PORTC.3
            
            J <font color="#000080">VAR WORD
            </font>i <font color="#000080">VAR WORD
            
            </font>c <font color="#000080">VAR BYTE
            </font>variabila1 <font color="#000080">VAR BYTE
            </font>variabila2 <font color="#000080">VAR BYTE        
            </font>variabila1=&quot;A&quot;
            variabila2=&quot;B&quot;
            
            i=0
            J=0
            
            ADCON1 = 7
            TRISB = 0
    
    start:
    
            <font color="#000080">I2CWRITE </font>SDA, SCL,$A0,i,[&quot;TEXT1&quot;,variabila1,&quot; TEXT2&quot;,variabila2]
            <font color="#000080">LCDOUT </font>$FE,1
            <font color="#000080">LCDOUT </font>$FE,$80,&quot;INCERCARI&quot;
            <font color="#000080">LCDOUT </font>$FE,$C0
            
            <font color="#000080">FOR </font>J = 0 <font color="#000080">TO </font>12
                <font color="#000080">I2CREAD </font>SDA, SCL,$A0,J,[c]
                <font color="#000080">LCDOUT </font>c
                <font color="#000080">NEXT </font>J
    
            @   <font color="#000080">GOTO </font>$
    Last edited by mister_e; - 27th March 2008 at 21:23.
    Steve

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

  3. #3
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    in your first example, try to change to..
    Code:
        lcdout $FE,1
        LCDOUT $FE,$80,"INCERCARI"
        LCDOUT $FE,$C0
    
        for J = 0 to 20
            i2cread SDA, SCL,$A0,J,[C]
            LCDOUT c
            next
    In this situation the fist karakter is write in the same place , first possition .

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


    Did you find this post helpful? Yes | No

    Default

    no it works here, look at post #10
    Steve

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

  5. #5
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Hi, something like the following will work.
    Code:
            EEP1    con %10100000 ' First EEPROM A<2:0>=Gnd
            ................................................................
        
            @ GOTO $
    I have write your code ..and display " ATEXT1 BTEXT2 " BUT NOT ALL TOGETHER -alternately . If will be remain all karakters on the display -ALL WILL BE OK !

    Addr var word
    ByteA var byte
    ByteB var byte

    PAUSE 50

    addr=0
    BYTEA="A"
    byteb="B"
    I2CWRITE SDA,SCL,$A0,ADDR,[bYTEA," TEXT1",BYTEB," TEXT2"]
    PAUSE 10
    reading:
    FOR ADDR=0 TO 13
    I2Cread SDA,SCL,$A0,ADDR,[bYTEA]



    lcdout $FE,1
    LCDOUT $FE,$80,"INCERCARI"
    LCDOUT $FE,$C0+addr ,ByteA ' HERE I WRITE " +ADDR " BECOSE HE WRITE IN THE SAME PLACE

    pause 300
    next
    pause 400
    Enable
    goto scriere
    Last edited by Eugeniu; - 27th March 2008 at 21:40.

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


    Did you find this post helpful? Yes | No

    Default

    POST #10, not #9

    anyways, look what your actual code do...
    Code:
    FOR ADDR=0 TO 13
    I2Cread SDA,SCL,$A0,ADDR,[bYTEA]
    
    lcdout $FE,1  ' it always clear your LCD and return to home
    LCDOUT $FE,$80,"INCERCARI" ' it always draw this line
    LCDOUT $FE,$C0+addr ,ByteA '  and finally here, it will only draw a single character, because you ALWAYS clear the WHOLE lcd with $FE,1
    
    pause 300
    next
    hence why i've move most LCDOUT BEFORE the FOR/NEXT loop.... twice.
    Steve

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

  7. #7
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    POST #10, not #9

    anyways, look what your actual code do...
    Code:
    FOR ADDR=0 TO 13
    I2Cread SDA,SCL,$A0,ADDR,[bYTEA]
    
          I understand that  : in this line " byTEA is a new variable where PBP put what read at "ADDR"  I have change with "C" and is the same .
    
    lcdout $FE,1  ' it always clear your LCD and return to home
    
          Aha , I will delete this line !! .....and WORK !! 
    
    LCDOUT $FE,$80,"INCERCARI" ' it always draw this line
    
          yes , I wish this .
    
    LCDOUT $FE,$C0+addr ,ByteA '  and finally here, it will only draw a single character, because you ALWAYS clear the WHOLE lcd with $FE,1
    
    pause 300
    next
    hence why i've move most LCDOUT BEFORE the FOR/NEXT loop.... twice.
    I understand , I have make changes in programs and now it work !

    Thank you very much for all help ! Have you only a happy days !

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


    Did you find this post helpful? Yes | No

    Default

    Grreeeeeeeeeeeeeat! Enjoy!
    Steve

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

  9. #9
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    "Have you only a happy days !"

    Quote of the day.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

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


    Did you find this post helpful? Yes | No

    Default

    ah come on... read first post
    Quote Originally Posted by POST #1
    My name is Eugen , from Romania - Bucharest .
    Chances are that our friend is not English, and try to do it's best... as i do each days since i'm here.... and yes i do tons of mistakes here and there, in each and every of my over 4,800 posts.

    Time to raise Melanie's post once again
    http://www.picbasic.co.uk/forum/showthread.php?t=4583
    Last edited by mister_e; - 27th March 2008 at 22:10.
    Steve

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

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55
  5. I need help with i2c memory
    By -c3- in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 23rd June 2005, 19:57

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