iicEEPROM read and write confusion

Discussion in 'Programmer's Corner' started by Jswale, Jan 5, 2016.

  1. Jswale

    Thread Starter Member

    Jun 30, 2015
    121
    6
    Hi All,

    I am working on an EVM430-F6779 using the MSP430...

    I am trying to write and read back from the EEPROM using I2C.

    The functions are pre-written, so I know are correct but I am unsure of how to use them/ what to look for.

    Code (C):
    1. int iicEEPROM_write(uint16_t addr, void *dat, int len)
    2.  
    3. int iicEEPROM_read(uint16_t addr, void *dat, int len)
    4.  
    5.  
    6.  
    7. //my attempts
    8. uint16_t dat = 0xFF;
    9.        
    10.          iicEEPROM_write(0xA0, &dat, sizeof(dat));
    11.  
    12.          iicEEPROM_read(0xA0, &dat, sizeof(dat));
    13.  
    Anyone with any advice on to why this isn't working?

    Cheers
    JSwale
     
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Hi.

    Which IDE do you use?
     
  3. Jswale

    Thread Starter Member

    Jun 30, 2015
    121
    6
    I am using the IAR Embedded Workbench 6.30.3
     
  4. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    OK, I thought it would be easier to work with the Energia IDE.
    I've never used it but I think it is similar to the Arduino IDE. With lots of libraries. I'm on thin ice here, so I might be wrong.
     
  5. Jswale

    Thread Starter Member

    Jun 30, 2015
    121
    6
    Yeah, I need to use the IAR workbench because of the supplied code for my development box. I am more interested in the syntax that I am having a problem with.
     
  6. Jswale

    Thread Starter Member

    Jun 30, 2015
    121
    6
    Code (C):
    1.                     {
    2.                       int *write_dat;
    3.                       int data = 5;
    4.                       write_dat = &data;
    5.                       iicEEPROM_write(0x20, write_dat, 1);
    6.                                      
    7.                       uint8_t value;
    8.                       iicEEPROM_read(0x20, &value, 1);
    9.                     }
    This is what I am working with. From what I can tell it should work... write '5' into address 0x20 with length 1 (byte??). Then the read from address 0x20 and store it at the address of 'value'.

    Can anyone spot an error?
     
Loading...