A help with Write/Read a I2C memory


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    60

    Default A help with Write/Read a I2C memory

    Hello !

    My name is Eugen , from Romania - Bucharest . I am a new in use PBP . Please help me to know where I wrong . I have a Pic16F877 , and I wish to write a one or two texts as connstant , and variables as hours , minutes , seconds (these are not writes in my example), on a I2C memory type 24FC512 ,Read memory and display on a LCD with 2X16 lines:
    *****************************
    define LOADER_USED 1
    define OSC 4
    INCLUDE "Modedefs.bas"

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 3
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 2

    SDA VAR PORTC.4
    SCL VAR PORTC.3

    J var word
    i var word

    c var byte

    I=0
    J=0

    ADCON1 = 7
    TRISB = 0

    start:


    DISABLE INTERRUPT

    FOR i = 0 TO 20
    I2cwrite SDA, SCL,$A0,I,["TEXT1",VARIABILA1,"TEXT2",VARIABILA2]
    pause 30
    NEXT i

    for J = 0 to 20
    i2cread SDA, SCL,$A0,J,[C]
    pause 30

    lcdout $FE,1
    LCDOUT $FE,$80,"INCERCARI"
    LCDOUT $FE,$C0+j ,c

    pause 400
    next J
    pause 400
    Enable
    goto start
    *****************************
    Thenk you very much !

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


    Did you find this post helpful? Yes | No

    Default

    Instead of "TEXT1", use [#T,#E,#X,#T,#1...etc]

    Don't overwrite your buffer.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  3. #3
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    Instead of "TEXT1", use [#T,#E,#X,#T,#1...etc]

    Don't overwrite your buffer.
    Do not work .

    "I2cwrite SDA, SCL,$A0,I,[#T,#E,#X,#T,# ]" = "bad expression "

    Thanks !

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


    Did you find this post helpful? Yes | No

    Default

    Oops, my bad... that's for serial stuff.

    Try:

    text var byte[5]
    test[4] = "T"
    test[3] = "E"
    test[2] = "X"
    test[1] = "T"
    test[0] = "1"

    I2cwrite SDA, SCL,$A0,I,[char test\5, {your other data to send} ]

    I don't know if the array is sent out lowest ([0]) or highest ([4]) first. Reverse array asignments if it comes out backwards.
    Last edited by JD123; - 27th March 2008 at 19:23.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I2cwrite SDA, SCL,$A0,I,[ "T" , "E" , "X" , "T" , "1" ].....
    should also work. (not 100% sure, haven't tried myself, but it should work)

    What you originally had was an embedded string, which PBP doesn't natively handle. ( "TEXT1" ). A byte array of characters as noted in the post preceeding can be used as a string, but is not really a 'string' as far as PBP is concerned.

  6. #6
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I2cwrite SDA, SCL,$A0,I,[ "T" , "E" , "X" , "T" , "1" ].....
    should also work. (not 100% sure, haven't tried myself, but it should work)

    What you originally had was an embedded string, which PBP doesn't natively handle. ( "TEXT1" ). A byte array of characters as noted in the post preceeding can be used as a string, but is not really a 'string' as far as PBP is concerned.
    I have tried again , and in other kinds , and do not work .

  7. #7
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=skimask;53213]I2cwrite SDA, SCL,$A0,I,[ "T" , "E" , "X" , "T" , "1" ].....
    should also work. (not 100% sure, haven't tried myself, but it should work)

    What you originally had was an embedded string, which PBP doesn't natively handle. ( "TEXT1" ). A byte array of characters as noted in the post preceeding can be used as a string, but is not really a 'string' as far as PBP is concerned.[/QUOTE

    I used this and not work .Read and display step by step only " T " ,first karakter .

    ........................................
    test var byte[5]
    test[4] = "T"
    test[3] = "E"
    test[2] = "X"
    test[1] = "T"
    test[0] = "1"

    ADCON1 = 7
    TRISB = 0
    TRISC = 0

    start:


    DISABLE INTERRUPT
    scriere:

    FOR i = 1 TO 20
    I2cwrite SDA, SCL,$A0,I,["T","E","S","T","1"]
    pause 30
    NEXT i
    ........................................
    Last edited by Eugeniu; - 27th March 2008 at 20:48.

  8. #8
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Apologize for my english, please ! Do not be angry .

    Eugeniu

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


    Did you find this post helpful? Yes | No

    Default

    Don't worry Eugeniu, there's a lot of people here, including me, who aren't english. We do our best and that's it. Your question was clear enough for me.

    Don't be afraid and don't give up!
    Steve

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

  10. #10
    Join Date
    Nov 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Don't worry Eugeniu, there's a lot of people here, including me, who aren't english. We do our best and that's it. Your question was clear enough for me.

    Don't be afraid and don't give up!

    Thank you , again ! My misyakes was very simple , for others , that "COLUMB EGG " but , I have lost a day , and my mind and eyes do not want to see they .

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