I2CWRITE problem


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    DATA var WORD [31]
    It's the same in any programming language.
    You declare the number of elements as a Human would say it
    "there are 31 elements in the array" (not correct in this case).

    Man I tried everything..
    2.2K resistors, even shortened the clock and data wired to about six cm each.
    it's really time for a new circuit to do the same test,
    but I don't know what else I could change.
    Last edited by Art; - 27th January 2010 at 01:11. Reason: I just get the urge to edit sometimes

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Art, Have you tried the page write mode for storing your data? True, you need a shadow array the size of the page you are trying to write but it is much faster to write a full page than individual bytes if you have any quanity.. Try these subroutines that I wrote a long time ago for an analog waveform generator using a single 24LC512 utilizing the page mode. This routine will store 7 diferent files, made up of 64 blocks of 128 bytes each. I hope this helps...

    CNTRL_BYTE CON $A0 'CONTROL BYTE FOR I2C EEPROM MEMORY (A0/A1 USED FOR CHIP SELECT)
    BLOCK VAR BYTE '64 BLOCK ADDRESS BYTE
    ADDRESS VAR WORD 'ADDRESS WORD FOR SERIAL EEPROM
    CNTROL_BYTE VAR BYTE 'CONTROL BYTE TO SEND TO SERIAL EEPROM
    STOR_DATA VAR BYTE[128]'STORAGE DATA ARRAY
    FILE VAR BYTE 'FILE STORAGE NUMBER 0 to 7

    '************************************************* ********************
    WRITE_EEPROM512: 'WRITE TO SERIAL EEPROM
    '************************************************* ********************
    ADDRESS = FILE << 13 'CALCULATE 12C ADDRESS TO STORE DATA TO
    ADDRESS = ADDRESS + (BLOCK << 7) 'CALCULATE 12C ADDRESS TO STORE DATA TO
    CNTROL_BYTE = CNTRL_BYTE 'COPY CONTROL BYTE
    CNTROL_BYTE.1 = 0' 'SET LSB OF HARDWARE ADDRESS
    CNTROL_BYTE.2 = 0' 'SET MSB-1 OF HARDWARE ADDRESS
    CNTROL_BYTE.3 = 0' 'SET MSB OF HARDWARE ADDRESS
    I2CWRITE SDA,SCL,CNTROL_BYTE,ADDRESS,[STR STOR_DATA\128] 'SAVE DATA TO 12C
    PAUSE 6 'ALLOW TIME FOR I2C WRITE ~5Ms.
    BLOCK = BLOCK + 1 'INCREMENT BLOCK NUMBER
    RETURN

    '************************************************* ********************
    READ_EEPROM512: 'READ FROM SERIAL EEPROM
    '************************************************* ********************
    ADDRESS = FILE << 13 'CALCULATE 12C ADDRESS TO STORE DATA TO
    ADDRESS = ADDRESS + (BLOCK << 7) 'CALCULATE 12C ADDRESS TO STORE DATA TO
    CNTROL_BYTE = CNTRL_BYTE 'COPY CONTROL BYTE
    CNTROL_BYTE.1 = 0' 'SET LSB OF HARDWARE ADDRESS
    CNTROL_BYTE.2 = 0' 'SET MSB-1 OF HARDWARE ADDRESS
    CNTROL_BYTE.3 = 0' 'SET MSB OF HARDWARE ADDRESS
    I2CREAD SDA,SCL,CNTROL_BYTE,ADDRESS,[STR STOR_DATA\128] 'LOAD IN ENTIRE BLOCK
    RETURN

    Dave Purola,
    N8NTA

Similar Threads

  1. My I2CWRITE - timings and tricks
    By FinchPJ in forum Code Examples
    Replies: 5
    Last Post: - 3rd March 2008, 22:40
  2. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2006, 21:03
  3. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th June 2006, 19:32
  4. Another I2CWRITE problem
    By ErnieM in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th May 2006, 22:57
  5. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 19:26

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