jimmie
Junior Member
Posts: 86
|
Post by jimmie on Aug 9, 2019 16:20:21 GMT
I am reading a couple of variables from EEPROM using the code below.
The debug statements confirm that the results have been read correctly. HOWEVER, when I use this routine, Setup() does not complete and loops do not run.
I am sure it has to do with this sub because commenting it in Setup() causes everything to work as expected.
What is causing that?
Any help is appreciated and thanks in advance.
Here is the code:
void readDist2EEPROM() { int distAddress = 500;
for (int SN = 0; SN < 2; SN++) { str[SN] = ""; SerialASC.print("Reading EEPROM .... "); SerialASC.println(SN);
for (int j = 0; j < 5; j++) { str[SN] += char(EEPROM.read(distAddress + (SN * 5) + j)); } str[SN].trim();
v2G[SN] = str[SN].toInt();
SerialASC.print("Read "); SerialASC.print(SN); SerialASC.print(" = "); SerialASC.println(v2[SN]); } }
|
|
|
Post by Admin on Aug 12, 2019 10:27:01 GMT
It is likely that the string functions are causing problems with the malloc() as this is also used by the EEPROM driver. You could use the normal C functions from string.h (e.g. strcpy, strlen, strcpy etc.) as these do not use malloc and are supported.
|
|
jimmie
Junior Member
Posts: 86
|
Post by jimmie on Aug 12, 2019 13:59:09 GMT
It is likely that the string functions are causing problems with the malloc() as this is also used by the EEPROM driver. You could use the normal C functions from string.h (e.g. strcpy, strlen, strcpy etc.) as these do not use malloc and are supported.
Thank you. Will change but I wish the EEPROM function on the ShieldBuddy can be improved as it has been a source of endless frustration for me.
|
|