EEPROM command kills my LCD-display!

I dont know if it is the right place to put my issue here, because its a bit complicated, so sorry for that if its so.

i created my own arduino nano low power version. see pic
if any one is interested in the EAGLE FILE, i will upload it.

the board is working fine so far. the code (relevant parts shown) used is already tested before with standard arduino nano. no problems so far. in short, i first upload a sketch via USB where i write 2 float variables in to the EEPROM. after that i upload a sketch where it reads the floats from EEPROM and saves them to the variables Min and Max. and then i display the values on the LCD(with I2c). in standard opperation of the device i need to change these values by buttons and then save them to EEPROM again for use after reboot.

Now here is the Problem:
If i Upload the code via ISP-Programmer AVRISP MKII to my custom arduino the LCD freezes with black bars forever (ireversible, even if i upload a working sketch) and the arduino freezes too, i cant even reset the atmega. if i delete the EEPROM lines in the sketch, remove the lcd and upload to the same arduino and replace to a new LCD Display, it is working again. i am using an ATMEGA 328PB on my custom arduino. i destroyed 2 lcd until i found the problem. i have no clue whats going on here and i am not very experienced in programming. if anyone has an idea i would be very thankful!

#include "HX711.h" // GitHub - bogde/HX711: An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
#include "Wire.h"
#include <LiquidCrystal_I2C.h> // GitHub - johnrickman/LiquidCrystal_I2C: LiquidCrystal Arduino library for the DFRobot I2C LCD displays
#include "math.h"
#include <ButtonDebounce.h>
//#include <EEPROM.h>
#include "LowPower.h"

float Min = -5.0;
float Max = -3.0;

//float Min = EEPROM.get(0, f);
//float Max = EEPROM.get(4, f);

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
// Serial.begin(115200);

// float Min = -5.0;
// float Max = -3.0;
// EEPROM.put(0,Min);
// EEPROM.put(4,Max);

lcd.init(); //Im Setup wird der LCD gestartet
lcd.backlight(); //Hintergrundbeleuchtung einschalten (0 schaltet die Beleuchtung aus).

lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(7, 0);
lcd.print(Min, 1);
lcd.setCursor(7, 1);
lcd.print(" Max=");
lcd.print(Max, 1);

Your code is incomplete.

Please remember to use code tags when posting code

I forgot to say, that i am using minicore with the internal clock 8mhz.

i found out now, that the compiler overrides the eeprom upon uploading code, so it states "nan" at the serial monitor for the value of the float Min. so i am sending some kind of strange bit sequence to the lcd-i2c converter, possibly damaging the operating system of the i2c module?!

how do i use code tags?

I forgot to say, that i am using minicore with the internal clock 8mhz.

sp. "8MHz"

i found out now, that the compiler overrides the eeprom upon uploading code

It does? The compiler doesn't upload code...

how do i use code tags?

Like this [code][/code] (It's the </>" icon on the toolbar)

You do not destroy lcd’s with incorrect code. You are perhaps using incorrect settings for your crystal or other issues with the clock source. It would be a good idea to post the board schematic in pdf format.

Please code all of your code, with code tags.

nan means “not a number” which means you’re reading an invalid floating point number which happens when reading the wrong address.

It sounds like you have incorrect fuse settings when loading with the ISP.

Thank you for your help i solved this Problem by setting the Fuses and then the eeprom retains and the data send to the lcd is Not nan anymore. But noch ive got a similar Problem. I will open a New Topic. Its so strange....

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.