Go Down

Topic: 24C32 EEPROM - Can't get it work right (Read 2459 times) previous topic - next topic

KenshinPT

Hey friends :) How have you been?

I have been searching and trying badly to get an external 24C32AN from Microchip to work... without success so far.

This is the external EEPROM which cames with the RTC module -> DS1307 from Dallas.

The clock is working OK... I can write, read, whatever... on it's 56bytes NV SRAM.

Then I though: "Hey! Why not check how the the 24C32 works?"

I added this line of code:
Code: [Select]

#define E24C32_I2C_ADDRESS 0x50


and a little bit of this:
Code: [Select]


//Write data on 5th row
Wire.beginTransmission(E24C32_I2C_ADDRESS);
Wire.write(0x05); //choose the 5th row
Wire.write(decToBcd(10)); //write number 10 on memory
Wire.endTransmission();

//Read the written data
Wire.requestFrom(E24C32_I2C_ADDRESS), 1); //reads one byte starting on the latest position -> 0x05
newvar = bcdToDec(Wire.read());
lcd.setCursor(2,3);  //Set the cursor in the position number 2 (3rd char) on line 3 of the LCD.
lcd.print(newvar);



No idea why, but no matter which value I write, I get this decimal value of "165" ( 0b10100101 )

Do you guys have any idea what's going wrong?

Thanks for you help

Regards.







Erdin

Run the i2c scanner, http://playground.arduino.cc/Main/I2cScanner

If that is okay, write a byte and read a byte.

Why are you using decToBcd() and bcdToDec()?
I think in the history of memory chips, there has never been a memory that used bcd code to store data. Not on earth, not elsewhere in the universe.

KenshinPT


Run the i2c scanner, http://playground.arduino.cc/Main/I2cScanner

If that is okay, write a byte and read a byte.

Why are you using decToBcd() and bcdToDec()?
I think in the history of memory chips, there has never been a memory that used bcd code to store data. Not on earth, not elsewhere in the universe.


Thanks for letting me know the existence of I2cScanner :)

About the decToBcd() and bcdToDec(), I use them to read and write the DS1307! I also use them to store data on its free NV RAM.


Erdin

#3
Apr 28, 2013, 04:16 pm Last Edit: Apr 28, 2013, 04:21 pm by Erdin Reason: 1
The EEPROM happens to be on the same board as the DS1307, but they are different chips.

The I2C EEPROM on the RTC board should also be used to read and write bytes.
It has absolutely nothing to do with bcd code.

The Arduino has also EEPROM. You can read and write bytes to it.

KenshinPT


The EEPROM happens to be on the same board as the DS1307, but they are different chips.

The I2C EEPROM on the RTC board should also be used to read and write bytes.
It has absolutely nothing to do with bcd code.

The Arduino has also EEPROM. You can read and write bytes to it.



Thanks :) Now I know.

However, I can not try again :) I fried the arduino.

I used an external 12V power supply. I applied it into the Vin pin. (Vin and 5V output were not shorted) and the voltage regulator fried and shorted letting the 12V pass through.

Result: Atmega dead. Probably the RTC, EEPROM and LCD are also dead.

I just ordered a couple more of each :)

Thanks!




Erdin

12V to Vin should not be a problem.

Buying a new set is a good idea. That whay you can determine what is fried and what not.

If you use I2C devices or something like that, using the USB power is good enough.

KenshinPT


Why are you using decToBcd() and bcdToDec()?


Sorry about this again.

I am using the functions above to read and write on the available memory 56 byte NV free RAM.

To be more precise, I use one byte to store a value of an exact hour, that can be changed by the user.

As the RAM memory is NV, I believe I am good :)

But, am I doing anything wrong? So far its running OK.

Thanks :)

Erdin

That RAM is on battery. If the battery is empty, the data in that RAM is gone.
The EEPROM on that board always keeps the values (if you have such a board with RTC + EEPROM).
So does the internal EEPROM of the Arduino, it keeps it value.

You can store a single bcd-number in a byte. But please don't do that. A byte is 8-bits data and can hold 0...255. So use it as a variable.

BCD is for example used to display the time on a 7-segment display.
Also RTC (Real Time Clock) chips use internal registers with BCD code. That was done in the past to make it easy to display the time on a 7-segment display. Today the RTC chips still have BCD code in the registers (I whish they didn't).

KenshinPT

Thanks for the information :)

However the NVSRAM is not well explained in Wikipedia.

http://en.wikipedia.org/wiki/NvSRAM
Quote
nvSRAM is one of the advanced NVRAM technologies that is fast replacing the BBSRAMs, especially for applications that need battery free solutions and long term retention at SRAM speeds. nvSRAMs are used in a wide range of situations--networking, aerospace, and medical, among many others[1] --where the preservation of data is critical and where batteries are impractical


The DS1307 is a NV SRAM.
http://datasheets.maximintegrated.com/en/ds/DS1307.pdf

But a little further in the datasheet they state that the 56 bytes are: Battery Backed, General Purpose RAM with Unlimited Writes

Regards.

Go Up