jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 1, 2019 20:02:34 GMT
I would appreciate any help with EEPROM programming.
I have been able to write and read to the EEPROM. However, now, when I try to read or write, the ShieldBuddy just hangs.
I have tried everything.
1) Clearing EEPROM in Core 0 (seems to work)
EEPROM.eeprom_erase();
2) Initing EERPOM - worked before but now hangs
void initEEPROM() { SerialASC.println(">>>>>> EEPROM INIT"); if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised) { /* EEPROM is bad */ SerialASC.println( "EEPROM is bad");
while (1) { SerialASC.println( ".... bad"); ; } } SerialASC.println("EEPROM INIT COMPLETE"); }
3) Any read or write also hangs:
void readEEPROM() { SerialASC.print("Reading EEProm --->>> "); SerialASC.println( numEEPROMVariables);
for (int i = 0; i < numEEPROMVariables; i++) { str[i] = ""; for (int j = 0; j < 25; j++) { str[i] += char(EEPROM.read(i * 25 + j)); } str[i].trim();
SerialASC.print("str_read("); SerialASC.print(i); SerialASC.print(")= "); SerialASC.println(str[i]); } }
What am I doing incorrectly?
Thanks in advance
|
|
|
Post by Admin on Aug 2, 2019 8:11:55 GMT
Your example works here. Perhaps the EEPROM in your TC275 is messed up? Try this. EEPROM_test.ino (3.02 KB) If the EEPROM init fails, we erase the entire EEPROM and restart the processor.
|
|
jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 2, 2019 15:23:15 GMT
Thank you. I tried the code and it runs fine and wipes out the EEPROM.
Now, I try again my earlier code and, but same problem, the systems hangs on the statement:
if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised)
So it must be something else. Can you please take a look at my code and tell me if something is out of place? I am almost sure it is something specific to the ShieldBuddy like not instantiating an EthernetClient in LMU.
Thanks in advance
//========================================================================================== #include <EEPROM.h> #include "Wstring.h"
//========================================================================================== #include <SPI.h> #include <Wire.h> #include "Adafruit_SH1106.h" #define OLED_RESET 4 Adafruit_SH1106 display(OLED_RESET);
#include <SD.h> File myFile; //========================================================================================== #include <Ethernet.h> //========================================================================================== /* LMU uninitialised data */ StartOfUninitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have no initial values here e.g. uint32 LMU_var; */
String request = "";
int sensorNum; int sensorAngle[3]; float segAngle[3][16]; float segAngleSin[3][16]; float segAngleCos[3][16];
IPAddress myTCPserverIP; int myTCPserverPort;
IPAddress ipAddress; IPAddress subnet; IPAddress gateway;
int sensorBusyArr[3]; int sensorTrigTimeArr[3]; int sensorScansArr[3];
String myMessage[3];
EndOfUninitialised_LMURam_Variables
/* LMU uninitialised data */
StartOfInitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have an initial value here e.g. uint32 LMU_var_init = 1; */
int tcpPort = 3001;
const int maxScans = 153; const int sensorSegments = 16;
int numEEPROMVariables = 35;
int autoAdjust = 1; int bypassServer = 1;
bool acceptClient = true; bool disableSensors = true;
int address = 0; byte value = 0; boolean f = true;
String str [45]; String b;
int pos1 = 0; int pos2 = 0;
EndOfInitialised_LMURam_Variables
//========================================================================================== //Misc. Startup //========================================================================================== bool printDist = true; int numRep = 100; long cntRep = 0; double frequency;
//=================================================================================================================================================== //Web Server //=================================================================================================================================================== byte mac[] = {0x2C, 0xF7, 0xF1, 0x08, 0x29, 0x73};
int webServerPort = 5555; EthernetServer server(webServerPort);
EthernetClient TtcClient; //=================================================================================================================================================== int cloudPoints[3][maxScans][sensorSegments][2]; int truckHeight[3][maxScans]; int truckHeightAvg[3][maxScans]; int truckWidth[3][maxScans]; int offCenter[3][maxScans]; //=================================================================================================================================================== //Other //=================================================================================================================================================== int distVal; long timeNow; String myConn; int iCount; //===================================================================================================================================================
void setup() {
startTime = millis();
// Open serial communications and wait for port to open: SerialASC.begin(115200); //=======================================================================================
SerialASC.println(">>>>>> EEPROM INIT"); if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised) { /* EEPROM is bad */ SerialASC.println( "EEPROM is bad"); while (1) { SerialASC.println( ".... bad"); ; Reset_TC275(); } } SerialASC.println("EEPROM INIT COMPLETE"); }
|
|
|
Post by Admin on Aug 5, 2019 15:02:23 GMT
The problem is caused by having too much data in the LMU RAM. This crashes the malloc() used by the EEPROM driver. In this sketch, there is no real advantage in using the LMU RAM as the default data area is DSPR0 which is what setup() and loop() use.
|
|
jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 5, 2019 17:33:24 GMT
Thank you. I cleared ALL LMU variables. I can clear the EEPROM using the code you sent. However, after that, code does not get past: if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised)
I have a suspicion that it is somehow also affected by the Ethernet shield or the SD card?
|
|
|
Post by Admin on Aug 6, 2019 7:33:26 GMT
This works on our rig:
//========================================================================================== #include <EEPROM.h> #include "Wstring.h"
//========================================================================================== #include <SPI.h> #include <Wire.h> //#include "Adafruit_SH1106.h" #define OLED_RESET 4 //Adafruit_SH1106 display(OLED_RESET);
#include <SD.h> File myFile; //========================================================================================== #include <Ethernet.h> //========================================================================================== /* LMU uninitialised data */ StartOfUninitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have no initial values here e.g. uint32 LMU_var; */
/* Moved */
EndOfUninitialised_LMURam_Variables
/* LMU uninitialised data */
StartOfInitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have an initial value here e.g. uint32 LMU_var_init = 1; */
int tcpPort = 3001;
const int maxScans = 153; const int sensorSegments = 16;
int numEEPROMVariables = 35;
int autoAdjust = 1; int bypassServer = 1;
bool acceptClient = true; bool disableSensors = true;
int address = 0; byte value = 0; boolean f = true;
String str [45]; String b;
int pos1 = 0; int pos2 = 0;
EndOfInitialised_LMURam_Variables
String request = "";
int sensorNum; int sensorAngle[3]; float segAngle[3][16]; float segAngleSin[3][16]; float segAngleCos[3][16];
IPAddress myTCPserverIP; int myTCPserverPort;
IPAddress ipAddress; IPAddress subnet; IPAddress gateway;
int sensorBusyArr[3]; int sensorTrigTimeArr[3]; int sensorScansArr[3];
String myMessage[3];
//========================================================================================== //Misc. Startup //========================================================================================== bool printDist = true; int numRep = 100; long cntRep = 0; double frequency;
//=================================================================================================================================================== //Web Server //=================================================================================================================================================== byte mac[] = {0x2C, 0xF7, 0xF1, 0x08, 0x29, 0x73};
int webServerPort = 5555; EthernetServer server(webServerPort);
EthernetClient TtcClient; //=================================================================================================================================================== int cloudPoints[3][maxScans][sensorSegments][2]; int truckHeight[3][maxScans]; int truckHeightAvg[3][maxScans]; int truckWidth[3][maxScans]; int offCenter[3][maxScans]; //=================================================================================================================================================== //Other //=================================================================================================================================================== int distVal; long timeNow; String myConn; int iCount; //===================================================================================================================================================
void setup() {
// Open serial communications and wait for port to open: SerialASC.begin(115200); //=======================================================================================
SerialASC.println(">>>>>> EEPROM INIT"); if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised) { /* EEPROM is bad */ SerialASC.println( "EEPROM is bad"); while (1) { SerialASC.println( ".... bad"); ; Reset_TC275(); } } SerialASC.println("EEPROM INIT COMPLETE"); }
void loop() {
}
void setup1() { // put your setup code for core 1 here, to run once:
}
void loop1() { // put your main code for core 1 here, to run repeatedly:
}
/*** Core 2 ***/
/* CPU2 Uninitialised Data */ StartOfUninitialised_CPU2_Variables /* Put your CPU2 fast access variables that have no initial values here e.g. uint32 CPU2_var; */ EndOfUninitialised_CPU2_Variables
/* CPU2 Initialised Data */ StartOfInitialised_CPU2_Variables /* Put your CPU2 fast access variables that have an initial value here e.g. uint32 CPU2_var_init = 1; */ EndOfInitialised_CPU2_Variables
void setup2() { // put your setup code for core 2 here, to run once:
}
void loop2() { // put your main code for core 2 here, to run repeatedly:
}
|
|
jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 6, 2019 14:58:26 GMT
Thank you very much for your time.
Will try it.
|
|
jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 7, 2019 4:18:36 GMT
=================================================================
Thank you again.
I tried it. It is a hit and miss! Sometimes it works and sometimes it stops at:
if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised)
I am suspecting memory corruption due to a SH1106 i2c display and have filed a separate post. Is this possible?
|
|
|
Post by Admin on Aug 7, 2019 7:31:46 GMT
It would be good idea to move all variables out of the LMU RAM and see if that helps. There is only 32kb of this and if EEPROM is being used, this will take up a large part of this for the malloc().
|
|
jimmie
Junior Member

Posts: 86
|
Post by jimmie on Aug 7, 2019 8:00:59 GMT
Thank you for your help.
My LMU area is now empty. I was still having the same problem until I disabled my i2c devices (OLED and Frame EEPROM).
When the i2c devices were disabled, the EEPROM started working again.
Can i2c devices corrupt EEPROM or interfere with it?
|
|
|
Post by Admin on Aug 7, 2019 8:13:28 GMT
There is no obvious reason why the I2C should interfere with the EEPROM. You could try using the bit-bashed I2C. // Use SW I2C port on any two pins #include <SoftwareWire.h> This is an example: UnoIsTheSlave_SW_I2C.ino (2.59 KB)
|
|
|
Post by crazydoc on Apr 21, 2021 5:35:47 GMT
Hey, It seems that I have a similar Problem concerning the EEPROM with my TC375. As soon as I comment in this line, the code is no longer executed.
if (EEPROM.eeprom_initialise() == EEPROM_Not_Initialised)
Unfortunately, this also applies to the test program "EEPROM_test.ino". Is it possible that this "EEPROM_test.ino" code only works for the 275? Is there anything like this for the TC375?
Or is there another way to reinitialise the EEPROM?
Finally, I would like to write some float values into the EEPROM. Is there a suitable way (e.g. via a structure)?
Thank you very much already!
|
|
|
Post by Admin on Apr 21, 2021 16:21:10 GMT
The EEPROM is not supported yet on the TC375. This is on the wish list.
|
|
|
Post by crazydoc on Apr 21, 2021 19:13:39 GMT
ok thanks for this information.
Is there another way to permanently store float variables (calibration data) on the TC375 without defining the values directly in the code, yet?
|
|
|
Post by Admin on Apr 22, 2021 8:29:07 GMT
No but we hope to have the EEPROM support working by the end of April.
|
|