Pages: [1]   Go Down
Author Topic: 24C32 EEPROM - Can't get it work right  (Read 2110 times)
0 Members and 1 Guest are viewing this topic.
Portugal
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey friends smiley 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:
#define E24C32_I2C_ADDRESS 0x50

and a little bit of this:
Code:

//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.






Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Portugal
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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.

Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 28, 2013, 09:21:07 am by Erdin » Logged

Portugal
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley Now I know.

However, I can not try again smiley 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 smiley

Thanks!



Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Portugal
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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

Thanks smiley
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Portugal
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the information smiley

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.
Logged

Pages: [1]   Go Up
Jump to: