Jump into eeprom address


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46

    Default Jump into eeprom address

    Hi all,
    i'm receiving through a max232 a string (ex. XYTest Com1).
    With Serin2 I'm waiting for a string and if it has XY I save the following
    9 characters into a string (long).
    I save 'long' into a 24c64 eeprom with i2cwrite then i check with i2cread and
    Serout2 if long has been saved. After that I increase ADD by 9 and I jump
    to start waiting for the next available string.
    The first 3 strings are saved fine:
    Address 0000 Test Com
    Address 0009 1Test Co
    Address 0010 m1Test C
    Address 0018 om1
    Now when the fourth string is coming at address 27 (1B) the first 5
    characters are correctly saved into 27-28-29-30-31 (1B-1C-1D-1E-1F)
    and the last 4 are saved into address 0-1-2-3 instead of 32-33-34-35
    (20-21-22-23)
    Address 0000 Com1 Com
    Address 0009 1Test Co
    Address 0010 m1Test C
    Address 0018 om1Test

    I got lost, I do not understand why !!
    Thanks for your help.

    Here is the prg:

    DEFINE OSC 4

    SDA VAR PORTA.0
    SCL VAR PORTA.1
    ADD VAR WORD
    EEP CON $A0
    OUT VAR BYTE[9]
    long VAR BYTE[9]

    BAUD VAR BYTE
    RX VAR PORTA.3
    TX VAR PORTA.2

    BAUD = 84 ' 9600,8,N,1

    ADD=0
    Pause 1000

    Start:

    SerIn2 RX, BAUD, [wait("XY"),STR long\9]
    Pause 2000
    I2CWrite SDA,SCL,EEP,ADD,[STR long\9]
    Pause 10

    Pause 2000

    I2CRead SDA,SCL,EEP,ADD,[STR OUT\9]
    Pause 10
    SerOut2 TX, BAUD, [#ADD," ", STR OUT\9,13,10]

    ADD=ADD+9

    GoTo START

    End

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


    Did you find this post helpful? Yes | No

    Default

    Check if your particular EEPROM allows you to write more than one byte before initiating a 10mS wait - this information will be found in your manufacturers Datasheet for the device. You are outputting 9 bytes in one string with no delays, it is possible you are violating the timing requirement of the EEPROM. The fact the first strings are save correctly is no guarantee that any others will be.

  3. #3
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Melanie, thanks for yr reply.
    The eeprom is manufactured by ST. I checked the datasheet http://www.tranzistoare.ro/datasheets/400/227040_DS.pdf and according
    to the table nr. 16 the waiting time is for the N series 10ms.
    I really do not know what's wrong.
    thanks for any further help.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If they tell you 10mS, then you should give it 10mS PER BYTE and not 10mS AFTER sending nine bytes.

  5. #5
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Hi again,
    I feel this is might be a stupid question !
    It's enough (too easy) Pause 90 instead of Pause 10 ?
    Otherwise how can i make a 10ms pause after each byte ?
    Thanks again

  6. #6
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Red face

    A 90ms Wait ist not right.

    I think, the EEPROM can access its memory in pages of 32 Bytes.
    So, if you write inside this page, it can be written back in one event just needing 10ms pause.
    But if you are crossing this pages, you must adress the new page with a new I2C-Command.
    Just read the dokumentation and see, if if is possible for you to use pages. Maybe it will be ok, if you drop every 5 Bytes at the end of a page ?
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    SerIn2 RX, BAUD, [wait("XY"),STR long\9]
    Pause 2000

    For CounterA=0 to 8
    Address=ADD+CounterA
    I2CWrite SDA,SCL,EEP,Address,[STR(CounterA)]
    Pause 10
    Next CounterA

  8. #8
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    @ BigWumpus

    Yes you are right. I saw (datasheet) that Page Write mode allows up to 32
    bytes per writing cycle.
    Now let's see how to 'cheat' the 24c64 !

    @ Melanie

    Thanks for the code.
    Unfortunatly I receive a compiling error on line:
    I2CWrite SDA,SCL,EEP,Address,[STR(CounterA)] = Bad Expression
    I tried some small chances but no success.
    I'm sorry I'm not a Pro and I still need your help.
    Thanks

  9. #9
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Probably needs an intermediate variable because I don't think variable indexed arrays are allowed with I2CREAD or I2WRITE... try this...


    CounterA var BYTE
    DataA var BYTE

    SerIn2 RX, BAUD, [wait("XY"),STR long\9]
    Pause 2000

    For CounterA=0 to 8
    Address=ADD+CounterA
    DataA=STR(CounterA)
    I2CWrite SDA,SCL,EEP,Address,[DataA]
    Pause 10
    Next CounterA

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Bootloader and Instant Interrupts Atn:_DT_
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th May 2007, 01:59
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  4. External EEPROM Not getting data (24LC515)
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2005, 13:16
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

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