Shop OBEX P1 Docs P2 Docs Learn Events
Flash memory code help — Parallax Forums

Flash memory code help

This discussion was created from comments split from: Unable to WRITE data to eeprom.

Comments

  • Hi everyone,
    I want to communicate with flash mmory, I Need a sample C/C++ code to write a string into flash memory and read this again.
    i have tried a sample code but this is not working, i am getting unexpected output. attached screenshot.

    #include "simpletools.h"                      // Include simpletools header    .
    
    int main(void)                                // main function
    {
      ee_config(28, 29, 1);               // configure for driving scl, needed for some eeprom setups
    
      int addr = 19200;                           // Pick EEPROM base address. 
    
      ee_putInt(42, addr);                        // 42 -> EEPROM address 32769
      int eeVal = ee_getInt(addr);                // EEPROM address 32769 -> eeVal
      print("myVal = %d\n", eeVal);               // Display result
    
      ee_putStr("hello!\n", 8, addr + 4);         // hello!\n -> EEPROM 32773..32780
      char s[8];                                  // Character array to hold string
      ee_getStr(s, 8, addr + 4);                  // EEPROM 32773..32780 -> s[0]..s[7]
      print("s = %s", s);                         // Display s array
    }
    
Sign In or Register to comment.