Jump to content
developer_bt

Problem with EEPROM library and TM4C1294 Connected LaunchPad

Recommended Posts

I noticed a problem with the EEPROM library TM4C1294 Connected LaunchPad. 

I tried this example but without success: 



/* Example 31.1 - Arduino internal EEPROM demonstration
http://tronixstuff.com/tutorials > chapter 31 | CC by-sa-nc */
#include <EEPROM.h>
int zz;
int EEsize = 1024; // size in bytes of your board's EEPROM
void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop(){
Serial.println("Writing random numbers...");
for (int i = 0; i < EEsize; i++){
zz=random(255);
EEPROM.write(i, zz);
}
Serial.println();
for (int a=0; a<EEsize; a++){
zz = EEPROM.read(a);
Serial.print("EEPROM position: ");
Serial.print(a);
Serial.print(" contains ");
Serial.println(zz);
delay(25);
}
}


After reset only print "Writing random numbers ..."  and freezes. 

The same code works with TM4C123. 

I use the latest library from GIT.

Share this post


Link to post
Share on other sites

The variable zz seems to be an int while EEPROM.write writes a byte.

 

More generally, I recommend you to use the strong types int{8|16|32|64}_t instead of the weak types like int. int could mean int16_t or int32_t depending on the MCU.

 

Similarly, what type is required for the address?

Share this post


Link to post
Share on other sites

I did some testing on this, there's something odd about the TM4C129 EEPROM. Using the EEPROM.h library it hangs on writing. If I use ROM_EEPROMProgram it writes just fine (I think, doesn't hang anyway), but when I call ROM_EEPROMRead it hangs.

These calls work just fine on the Stellaris and TM4C123 launchpads.

 

I think next up is opening the 2 kilopage datasheet and trying to find answers in there. I do not have the brain energy for that right now, though.

Share this post


Link to post
Share on other sites

Just looked at the Energia EEPROM library - seems like could use some refinement.  (Like error checking (e.g. it takes an int argument as an address

but doesn't check for negative addresses), checking for error returns, API to get EEPROM size, etc.)

Also, none of it seems to check for TM4C123 devices where the EEPROM can brick the device.

 

Have you tried checking the return codes from write when you use driverlib?  Checking EEPROMStatusGet() after using the EEPROM library?

Have you tried using the non-ROM versions of driverlib? (doesn't look like any fixes in the RAM version, but might be worth confirming).

Share this post


Link to post
Share on other sites

Hello,

 

the EEPROM library comming with Energia doesn't work or me neither, but after some changes I've been able to successfully write and read the EEPROM on my TM4C1294.

As stated on e2e forum, the EEPROM should be enabled like any peripheral. I've put the initialization code from the e2e page in a new EEPROM methode:

void EEPROMClass::init(void)
{
  SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);  //#include <driverlib/sysctl.h> also necessary
  EEPROMInit();  
}

More than that, the ROM functions in driverlib don't work, but the "non ROM" ones do => I've changed the library to use these ones.

Attached are the changed EEPROM files (.h & .cpp).

I haven't done any improvement (as suggested by Igor) to the library.

Hope this helps someone!

 

Regards,

Liviu

EEPROM.cpp

EEPROM.h

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...