================================================================================================================================================

Friday, August 15, 2008

Interfacing RTC & serial EEPROM using i2c bus, with ATmega128 uC






















Hi friends,
here is my experiment with i2c bus for interfacing serial EEPROM (24C256) and RTC (DS1307) using AVR microcontroller ATmega128. The circuit is also provided with an RS232 port for connecting with PC to send commands for reading/writing EEPROM or setting date/time in RTC (Click on images to enlarge them).

Communication with PC is done through Hyper Terminal. A screen shot of the message sent to PC by microcontroller immediately after power ON is shown in the figure at the left, where the user is asked to enter choice from the menu options related to EEPROM and RTC. User can store data in EEPROM, or set RTC date and time by entering them using PC keyboard.
Hyper Terminal is used with 19200 Baud, No parity, No hardware flow control settings.

When the circuit is powered on, a welcome message is displayed on the Hyper Terminal window and a menu with 9 options (0-8) is displayed (refer to the figure). The options are explained here:

0: Erase EEPROM (fills eeprom with 0xff bytes)
1: Write EEPROM (starts writing eeprom starting with 0x0000 address)
2: Read EEPROM (reads eeprom starting with 0x0000 address)
3: Write eeprom page (writes one page of eeprom at specified page number)
4: Read eeprom page (Reads one page of eeprom at specified page number)
5: Display RTC Date (Displays current date from RTC)
6: Display RTC time (Displays current time from RTC)
7: Update RTC Date (Setting new date in RTC)
8: Update RTC time (Setting new time in RTC)

The option is selected from PC keyboard. While writing to eeprom or RTC the data is entered using PC keyboard as specified by the program.

The software routines include DS1307 library, 24C256 library & I2C library along with the main function.

The code is written in C using winAVR (inside AVRStudio). The complete project folder can be downloaded here in zip format (updated on 25-April-2009, earlier it was in ICCAVR format):

Here is running simulation on Proteus ISIS (click on image to enlarge it):


Downloads
------------------
Complete Source code (winAVR, AVRStudio-4 format)
Proteus Simulation Model


Datasheets:
ATmega128DS1307FM24C256,  MAX232

Thanks!

(last updated on 25-April-2009)
---------
ccd@dharmanitech.com

115 comments:

manojkumar said...

Hi Dharmani, this is manoj. I want to know its function and brief explanation of the circuit if possible. And send the library function u have created, i will try to understand it. My ID manojlenin@gmail.com

Bina said...

Hi Dharmani, Iwanto try your project would you send me the complete files to bina.pratomo@yahoo.co.id
Thanks.

CC Dharmani said...

Thanks for your interest,guys!! I've sent u the program files, hope u find them useful.. post here if any doubt is there..
Thanks.

Anonymous said...

hi...i'm interested in this EEPROM..By the way, can i use it in Microchip PIC?
Please send me the files at bbs_aries@yahoo.com for me to try it..thanks

CC Dharmani said...

Hi Aries,
yes, you can use PIC micro with this EEPROM. Actually, any microcontroller having i2c bus can be interfaced with this EEPROM.
I've sent you the files, they'll need some modifications as they're written for AVR controller.
Thanks!

CC Dharmani said...

Hi Henric,
I've sent you the source code and header files (total 6 files, zipped) at your mail id. Mail me or put up a comment here if any problem in receiving or any remarks about the libraries.

Regards.

CC Dharmani said...

To Hossein:
Hi, I've sent you the complete source code in zip format, as u requested by mail. If any problem in receiving the files, put up your comment here or write to me.

Regards.

Anonymous said...

Hi Dharmani, I want to try your project. would you like to send me the complete files to andi2302@gmail.com
Thanks.

CC Dharmani said...

Hi 'andi',
I've sent you the code on your email id, check it out!

Regards.

Chetan Jain said...

Hi Dharmani, this is Chetan from Mumbai.. I'm working on a project which involves Atmega128 and the storing of incoming data into its memory with the corresponding real time value. For this i wish to use the in-built RTC system at timer/counter 2 of Atmega128. But as it seems for your project, you have used an external RTC 'DS1307'. So, i was wondering if the internal RTC would lead us into some bugs. Would you guide us with the above confusion and suggest some alternate method for our requirement. Thank you.

CC Dharmani said...

hi Chetan,
If you use internal Real Time Counter of ATmega128, the programming overhead increases as you have to write a code to keep counting the pulses, convert them into seconds, minutes, hours etc. Also, the program has to keep track of change of the day, month, 30 or 31 day month, leap year etc.
Apart from this, you have to keep the MCU always powered ON. If you provide battery backup, it'll consume more power than an external RTC.

If you use extrenal RTC like DS1307, all the calculation of day/date/month etc. are done inside. Whenevr you want to know the time, you've to just read the registers of the RTC and you'll get current time in hour/minute/sec with date/day and year.
Plus, even if the system is powered off, the RTC keeps running with external 3v lithium cell (which can last for years). So, next time when you power on the system, you'll get current time ready!

So, for your application, to have the real time-stamp on the data stored in memory, it would be much easier to use an ext. RTC. RTC chips are available cheap and they take only two pins of the microcontroller for communication.

Regards.

...fire cube said...

Hi Dharmani, this is Shiv .I want to try your project can you send me the files regarding this project. My ID is hurricane.shiv@gmail.com

Also help me with the programmer and the software needed for programming the IC and for establishing the connection between the PC n circuit.

Thank you

Chetan Jain said...

Hi Dharmani, this is Chetan once again. I really appreciate your efforts to help me out. But, as you pointed out, let me tell you that my requrement is just for the time and not the day, month, etc. So, if the internal RTC can be easily programmed for the timing alone, then i may not have to switch to an external RTC.

Secondly, as you said that the RTC consumes a lot of power and need to be switched on all the time, my application actually needs the system to be turned on all the time. So, i guess, the power consumption may not be an issue for me, but if the programming part is somewhat easy, then i was thinking of doing it with the internal RTC. Otherwise, if you think the other way, please let me know, and also, if you could help me with the coding of the external RTC, if required.
Thanks once again.

chetan8.jain@gmail.com

CC Dharmani said...

To Shiv:

Hi, I've sent you the code by mail. check it out!

Unknown said...

Hi dhramani sir,

we r working with atmega 32. we r succefully initialise lcd. now we have confussion with adc.
we want the information about temp conversion program with LM35

CC Dharmani said...

Hi Chetan,

since you need only time and the system is powered on all the time, you can do it with the internal RTC also. You have to just take care of any power failure so that you don't loose the current time.

For using internal RTC you have to use Timer/Counter0 (refer to datasheet). Set AS0 bit in ASSR register, connect 32.768KHz crystal between pins TOSC1 & TOSC2. Set timer0 prescaler to 128. This will make timer0 overflow at every 1 sec interval. You can then put in the code to count the seconds and convert them into minutes/hours.

RTCs don't consume lot of power but they need constant power (regular supply or battery back-up) for maintaining time.

If you want to use external RTC, I've given in this post the 'Download Code' link where you can get the DS1307 & I2C libraries.

CC Dharmani said...

Hi Swati,

since LM35 gives voltage output (10mv/C), you can connect the output pin of LM35 with any ADC channel (if you are not using channel-0, then connect it to channel-0).

Refer to my post:
http://www.dharmanitech.com/2008/10/adc-project-with-atmega32.html

There I've given code and schematic on how to use mega32 ADC for measuring voltages. Once you know the voltage o/p from LM35, just to divide it with the sensitivity (10mV/C) to get the temperature in Centigrade.

...fire cube said...

Hi Dharmani, this is Shiv .Can you suggest me a text book for -Programming of ATMEGA128(AVR) in both C language and ASSEMBLY language..or in case u have any E-Book regarding the same can u mail it to me at hurricane.shiv@gmail.com . I have a month time so i wanted to have through knowledge of the AVR programming.

Thank you...!

CC Dharmani said...

Hi Shiv,
there are some books on AVr, you'll find them if you search on net. But I won't be able to suggest any as I've never gone thru any book on AVR.
I usually prefer to go thru the datasheet, download a compiler and go thru its example programs. Start with a simple port interfacing (like flashing an LED) and then keep learning other modules like UART, TWI, SPI by programming and referring to datasheet.
It won't take longer as there is lot of help available on net for AVRs. You'll get code examples for almost anything in AVR.

Rachmanbobo said...

Dharmani at India, I have old IC paralel EEPROM 27256 from my VGAcard (VIDEO BIOS?) could u design for me the scheme how to display 8 bit data from that? thanks (i want make matrix LED e-toy)

CC Dharmani said...

Hi satpambobo,
27256 is an UV erasable EPROM. For reading from it you need a microcontroller.
I think you want the toy to display variable patterns. If it is so, you can rather use a microcontroller with inbuilt flash (like the AVRs), this will eliminate the need of the 27256 and also, you can erase/rewrite it whenever you want electrically (rather than searching for UV light source to erase 27256).

Regards.

Rachmanbobo said...

thanks 4 u reply. but mine, doesn't have hole glass to erase with UVlight. i think it's Electronicaly EPROM. I found Alan Nishioka Page that use 4040 counter to play 27256.

...fire cube said...

hi Dharmani. if i wish to use 89c51 ..can u suggest what could be the possible changes in interfacing rtc n eprom u have used for atmega and also what would be the change in programs u have provided...!

CC Dharmani said...

To Shahi:
Hi shiv, left the thought of using avr? :)
Anyways, as 8951 doesn't have i2c in hardware, you'll have to create low level functions to handle i2c bus timings, using two i/o pins of 8951.
In the program which i've provided, you'll have to replace the i2c library with your new library of software i2c. remaining routines you can use without changes.
Search on the net, there are many examples on how to write software i2c routines.

amol said...

can i use same programme for atmega 16? I want to store values of temperature,pressure and level in eeprom and want to display the same value at any time with date and time
Name Amol Suryaji Chaudhari
ID coolchaudhariamol@gmail.com

CC Dharmani said...

Hi amol,
interfacing these RTC & EEPROM will need i2c bus, and since the atmega16 is having it, you can certainly use it.
You'll have to change the program little bit, mostly the header file, to use it with ATmega16.

Anonymous said...

Hi Dharmani,
I Used your RTC and i2c libraries and I'm very happy with it. I added a function to set the sqw output, my avr is now using the ds1307 rtc and it run a state machine, clocked by the ds1307 sqw on the ext int0 (sec). Very nice!
Now I try to add functions to read and write to the ds1307 sram. For some reason, I do not get back what I write to it. Do have a sample for these functions lying around, or do have a hint why I don ot get the same value back that I wrote to a memory location?
In RTC_routines I added functions for read and write like this:
i2c_sendAddress(DS1307_W)
i2c_sendData(address);
i2c_sendData(IObyte);

Best regards, Kopke

Anonymous said...

Sorry, made a type in my code, the return type was not good. All is working ok now! Thanks for the inspiration you brought me!

CC Dharmani said...

Glad to know you solved it soon!

Regards.

Anonymous said...

hi Dharmani,
I want complete my project monitoring humidity and temperature, result monitoring save on SD/MMC and display on LCD 20x2,,but i can't display date from ds1307 and valid data from SHT11,please give me complete code on c language i am use compiler codevision avr,,
i am connect
SHT11
pin DATA to ATMega8535 port D2
pin SCK to ATMega8535 port D3

LCD
pin LCD to ATMega8535 port C

SD/MMC 1Gb
ATMega8535 port B5(MOSI) to pin SDO SD/MMC
ATMega8535 port B6(MISO) to pin SDI SD/MMC
ATMega8535 port B7(SCK) to pin SCK SD/MMC
ATMega8535 port B1(T1) to pin CS SD/MMC

RTC DS1307
pin SDA to ATMega8535 port B1
pin SCL to ATMega8535 port B2

serial port (USART) ATMega8535 to PC
you can send code to my mail ardi_sandi302@yahoo.co.id

tanks your attention and solution

CC Dharmani said...

Hi,
nice project! I've sent you the source code files for my project given in here. The files are written in ImageCraft ICCAVR compiler. you can easily convert them into CodeVision by making a few changes.

Regards.

amol said...

sir I want the information regarding pressure sensor,
level sensor and rpm measurement.
give the sensor's names.

Anonymous said...

Hi....

Im trying to interface EEPROM with 8051 in C language. I have written a code also for it, but its not working. Can u send some code related to this on this mail id-
engg.embedded@gmail.com
Thanks in advance...

CC Dharmani said...

Hi,
I've sent you the EEPROM & ic libraries. But, since the AVR controllers are having inbuilt i2c(TWI) bus hardware, the AVR i2c library will not be of much use here. You have to replace it with the software i2c library written for 8051 controllers to use the EEPROM library functions I sent.

Rizki said...

Hi Dharmani,
Your Project is very good.I wanto try your project would you send me the complete files to xrizkix2000@yahoo.com
Thanks.

CC Dharmani said...

Thanks Rizki! I've sent you the files.

Anonymous said...

hi,

Your project is really good to learn from. Thank you!

Could you explain just a bit how the multiplexing of the I2C from the microcontroller to the RTC chip and the FRAM chip is done? It looks like that when you initiate I2C protocal to the FRAM chip, the RTC chip would be affected as well and vice versa. Thanks.

CC Dharmani said...

If you go thru the I2C bus details, you'll find that every device on the I2C bus has a unique address. The microcontroller sends the address on the bus before sending any data, so only the device whose address is matching will respond to the data. All other devices on the same bus would just ignore it.
This is the advantage of using I2C bus, with just two wires, you can connect multiple devices with different addresses. You do not need a separate 'chip select' signal for every device to enable or disable it.

amol said...

I am getting problem with serial communication i have used atmega16 8 Mhz crystal and boud rate 9600
hyper terminal shows only '@@@@@@'
plz solve it

kumpulsahabat said...

hi dharmani, i have digitalclock project.
use RTC ds1307 and AT89s51, display 7segment. i wnt to make 5 slave and send with serial communication use rs485. please help me.
thanks

Moses said...

Hi! Dharmani,
I found your site to be very useful. I've managed to interface DS1307 RTC with 89C51RD2 successfully and also able to read & write to the 56Byte RAM available. I want to write the date/ time stamp and temperature to AT24C512 Serial EEPROM. Some how I'm getting an Error. When I run my EEPROM routines It works fine, in combinatio with RTC it fails showing garbage values. Can you please help me with the EEPROM routines? I want to write in locations 0 to 30,000.

If you have any eeprom program please email me

Thanks in advance!

Moses said...

Hi! Dharmani,
I found your site to be very useful. I've managed to interface DS1307 RTC with 89C51RD2 successfully and also able to read & write to the 56Byte RAM available. I want to write the date/ time stamp and temperature to AT24C512 Serial EEPROM. Some how I'm getting an Error. When I run my EEPROM routines It works fine, in combinatio with RTC it fails showing garbage values. Can you please help me with the EEPROM routines? I want to write in locations 0 to 30,000.

If you have any eeprom program please email me at 17.moses@gmail.com

Thanks in advance!

Anonymous said...

hi dharmani, i have digitalclock project.
use RTC ds1307 and AT89s51, display 7segment. i wnt to make 5 slave and send with serial communication use rs485. please help me.
thanks
send me at: imron.polines@gmail.com

Anonymous said...

hi dharmani, i have digitalclock project.
use RTC ds1307 and AT89s51, display 7segment. i wnt to make 5 slave and send with serial communication use rs485. please help me.
thanks
imron.polines@gmail.com

immroon said...

hi dharmani, i have digitalclock project.
use RTC ds1307 and AT89s51, display 7segment. i wnt to make 5 slave and send with serial communication use rs485. please help me.
thanks
imron.polines@gmail.com

Unknown said...

hi,

i need to try your porject, could you send me the files? my email is luix_mac@hotmail.com


thanks for your time
luis

Anonymous said...

Hi Dharmani, I'm interested in the DS307 library you mentioned.

Can you send me the files.
Thanks a lot!

Here is my email :

v2102ap@gmail.com

Anonymous said...

Also, if you don't mind, what is the program you used for drawing the schematics? Where can I download it?

Thanks again!

CC Dharmani said...

Hi, I've sent you the files.
I use EAGLE for drawing schematics, you can download it from this link:
http://www.cadsoft.de/download.htm

asif said...

hello

i am using your program and have worked on. But there is a problem how to write data in RAm of DS1307. when i write data in RAm it stops upgrading time. plz help me to solve this

asif said...

you can reply me on asif164@ohtmail.com

Althaf said...

I want to try to implement this RTC and serial EEPROM using I2C bus. Could you plaes send me the complete project files (schematics+sources+libs)
Regards,
Althaf
msheikalthaf@yahoo.com

Anonymous said...

would you send me the complete project file. i just want to learn your project, it seem very interesting.
Regards,
Iman
iman_parta_kusuma@yahoo.com

i will wait for your e-mail...thanks

sumeet singh said...

Great Article ! Can you please help me change the header files to use atmega32 instead of 1280 . i would be greatful if you can send me modified files to webrains@gmail.com

cheers
sumeet

Unknown said...

please tell me how to interface i2c to atmega 8535 as i didn't find any sda and scl pin in it

Unknown said...

how to interface i2c to atmega 8535

CC Dharmani said...

Hi Rahul,
Atmega8535 is having i2c bus (TWI) on-chip. Pin22 & 23 are SCL & SDA pins respectively. You can use i2c functions provided in this post.

Unknown said...

Hi Dharmani sir,
I am from jodhpur presently student of MBM Engg college.
I used your rtc interfacing code for atmega8 and it really worked very
good. I am very thankful to you for this help. Sir, I want to share my
further problem regarding to my project please help me.

It uses timer1 in ctc mode at almost 500ms delay. Each time
it flips a volatile uint8_t TIMER_FLAG. An another code in main program
activates whenever TIMER_FLEG is not zero read rtc and display SS/MM/HH
to hyper terminal. This code also flip a LED each time also. It works quite
well.

Along with timer1 It also uses INT1 in falling edge trigger mode. INT1 ISR
disturbs the previous code and bring the compiler out of previous and send
another message to hyper terminal. It also works quite well.

Problem is that sometime (after few minutes or several minutes) all of
sudden LED stops flipping as uC were gone in sleep mode. As soon as INT1 is
applied LED again starts flipping. I have take a number of tests for debuging
but failed to find fault. microcontroller uses internal 8MHz oscillator.
INT1 is applied through a TSOP1738 (Vout of TSOP is connected at pin D3) and
a normal TV remote. It is not using any type of sleeping mode.

//////////////////////////////////////////////////////////
/* I used timer in no prescale mode for pssible removal of
problem so I used LED_cnt to increase delay*/
////////////////////////////////////////////////////
ISR(TIMER1_COMPA_vect)
{ if(LED_cnt>=50)
{
LED_cnt=0;
TIMER_FLAG=1;
}
else
LED_cnt++;
}
////////////////////////////////////////////////////////////
SIGNAL(SIG_INTERRUPT1)
/* signal handler for external interrupt int1 */
{
INT_flag=1;
}
////////////////////////////////////////////////////////////

//////// main program///////////////////////
void main():
{
while(1)
{
while(!INT_flag)
{
if(TIMER_FLAG)
{
TIMER_FLAG=0;
bit_flip(PORTD,1);
....... .
////////////code to send SS/MM/HH to hyper terminal////////////
........
.......
////////////////////////////////////////////////////////////
}
}
uartsendstring("interrupt called");
INT_flag=0;
}
}

Please suggest me some solution to remove this problem.

Unknown said...

hi, this is poonam .i ma working on same project.can you tell me that why eeprom is used with RTC
can you send me details on poonamkothawade@yahoo.co.in

Unknown said...

Hi i am working on with the rtc1307 with 8051. When i tried entering the time through serial com port through the pc the controller resets again.
I have taken the code from the 1307 datasheet. Plz help
dis is d link of the code

http://www.maxim-ic.com/appnotes.cfm/an_pk/95

and dis is my email:
plz reply

pradeep.mirchandani@gmail.com

Bravo13 said...

Hello! I send mail to author and repost my troubles here
I'm using ATMega16 and AT24C128 EEPROM. Also, I use this datasheet www.atmel.com/atmel/acrobat/doc0670.pdf
First of all I'd want to clarify erasing algorithm. As I see, you use "page write" algorithm to write 0xFF bytes to whole memory. But it's not writing to whole memory, it's write only first page. In datasheet on page 10 quote

If more than 64 data words are
transmitted to the EEPROM, the data word address will “roll over” and previous data will be
overwritten. The address “roll over” during write is from the last byte of the current page to the
first byte of the same page.

I'v write new erasinc procedure, that erasing by pages. If I'm not right - correct me.
Second moment - delay between stop and start conditions. If I try to write two bytes in sequence, MCU hangs up when waiting start condition for second write procedure. But if I make delay between two write procedures, everything is Ok. In datsheet somsing about ACKNOWLEDGE POLLING on page 10 but I don't know how to embed it in your code. But your routines help me great - thank you. Could you help me in my two troubles?

Anonymous said...

Hi mr Dharmani and hello from Canada.
I find your article very usefull and well written, and I am trying right now to port the code to an ATmega 644.
I have changed a few things but it still does not work. I am not completely new to atmega but I am to AVRstudio and I am a bit lost!! can you help me on that one. I understand I have to modify the ports allocation: i2c on port C and rs232 on port D.
Then I went on the project settings, in fact I created a new project with a 644 at 20mhz clock. It compiles with no errors but I get those messages in the message window:
Loaded plugin STK500
Loaded plugin AVR GCC
Loaded partfile: C:\Program Files\Atmel\AVR Tools\PartDescriptionFiles\ATmega128.xml

I am not to sure about the implications of these, can you clarifie this to me.
AVRstudio is truly a great suite but finding my way around is somewhat complicated by the fact that I am completely new to GCC and that sort of things, I whish there was a single for it!
Thanks, Luc

John said...

Hello

My name is John and I am trying to store and then display nmea strings from a gps using the mega324p with an i2c eeprom.

I have managed to write all the nmea strings to the eeprom, my problem is now to try and read and display them in Hyper Terminal.

At the moment in my circuit simulator I am able to see the data being stored, but when I try and read the data that has been stored it does not go the eeprom addres I was expecting.

I am using a RS232 conection to the pc.

Here is the c code:

#define EEPROM_RD 0xA1
#define EEPROM_WR 0xA0

TWI_Start();
TWI_Write(EEPROM_WR); // write command
TWI_Write(0x00); //MSB
TWI_Write(0x01); //LSB
TWI_Start();
TWI_Write(EEPROM_RD); // read command
// TWI_Write(0x00); // Address what I


TWI_Read();


TWI_Stop();

/*Functions for write and read from the EEPROM*/

void TWI_Start(void)
{
TWCR = 1<< TWINT|1<<TWSTA|1<<TWEN;// repeated start condition
while(!(TWCR & 1<<TWINT));
}

void TWI_Write(uint8_t data)
{

TWDR = data;
TWCR = 1<< TWINT|1<<TWEN;
while(!(TWCR & 1<<TWINT));

}

void TWI_Stop(void)
{

TWCR = 1<< TWINT|1<<TWSTO|1<<TWEN;
_delay_ms(1);
}

//* TWI Read Function *//

uint8_t TWI_Read(void)
{

// start read transmission
TWCR = 1 << TWINT | 1 << TWEN;
while (!(TWCR & 1 << TWINT));
return(TWDR);// returns the data from the written file.

}
my email address is tuckerj1@aston.ac.uk.

Please feel free to give me some tips.

Many thanks for your time.

John

Unknown said...

Hi Dharmani, this is kumar. from past week we tying to interface ds1307 with atmega32 we have tried al the codes ...but can't.so please help us

amien said...

hi dharmani, Can you give examples of programs with codevision. The same with your schematic. this is email(amin3vdc@gmail.com)

Anonymous said...

Hi Dharmani sir,this is Mithilesh. we are working on a project,data logger into micro sd card , but we are facing problem with interfacing it with microcontroller.Can you please help us out..my email id is mithilesh1dhupia@gmail.com

CC Dharmani said...

Check out my post on microSD card interface with AVR:
http://www.dharmanitech.com/2009/01/sd-card-interfacing-with-atmega8-fat32.html

hot ladies stuff said...

please help me on how to interface micro SD card to ATMEGA8535..kindly please let me know..:)

Unknown said...

hello sir,i am a beginner in Embeddedsystem.can u send me notes on Embedded C and how to write sourcecode for a task.my id is punit05.namdeo@gmail.com

Anonymous said...

Hi Dharmani,
Quick question, the erase function does not work for me, any idea if I should be adding the repeat start ondition in the for loop, cause as per the simulation in ISIS only the first page i.e page 0 seems to get erased. All other pages stay intact even after erase.

mani said...

hlo dharmani.
I am building a room scanner bot using atmega16 and want to interface rtc and eeprom as you did. Kindly send me the complete description on mani2246@gmail.com it will help me a lot

Rinki Arora said...

can u please post one sample program for analog comparator using atmega162.

manisha said...

Hello Sir,i am working on project where I am using RTC 1307 and EPROM 24c04 to display time and when interrupt come, controller should capture that time and save it on eprom memory.Would you please tell me the c code for it.I am working with AT89C51 controller.

Unknown said...

hi dharmani sir, this eeprom function is used only one eeprom (24c256). but i want connect 4 eeprom. how to write coding sir, eeprom has four difference address modes, so how to select purticular address of eeprom and write sir, please help me

chemixbahi said...

hey guyz iam ssebabi godfrey,
can u pliz get the full c code for interfacing PIR sensor with MCU atmega128 avr

tewodros said...

hi dhramani
i want to interface atmel eprom AT27LV010A OTP EPROM for my project
and i don't know how b/c on the data sheet in programing mode it needs 13v vpp so how to do this with atmega 32 please help me

T.V.S.Kuthsav said...

Dear Dharmani,
Can you send me all the files,function codes to my mail drtvskuthsav@gmail.com
Thanks in Advance
-Kuthsav Thattai

tenb said...

Thank you very much!!!

้http://www.10logic.com

Anonymous said...

Hi! Dharmani,

this is Michael!
i was looking to your web and i found what i m looking for,
i m trying to save captured frame from a camera device to the 256K EEPROM,the cam frequency is 13.5MHZ and in your code you didn't mentioned anything about the TWI frequency neither you imported the ,please leave a reply on mickel-haddad@hotmail.com,

thanks in advance,

Michael .

Anonymous said...

hai dharmani,

My self ravi...

i would like to interface rtc DS1307 and EEPROM 24C04 to 8051 micro controller using i2c communication i have written individual codes for both working fine but when i am combining both it is not working can u please help me.....

my mail id: ravidegala74@gmail.com

JCrx7 said...

Hey, this works great... but I have maybe a noob question ... but.. why it is not the max232 ic on proteus? I test it and it works without it but when I connect it to a max232 (on proteus) it doesn't work... should I use always serial comunication on proteus without max232?

CC Dharmani said...

@Jcrx:
In proteus, the virtual terminal supports direct UART signals, not RS232 level signals. Hence, you need to use the terminal without MAX232. If you want to use MAX232, you need to use two of them for converting the UART level to RS232 level and then back to UART, just the way it happens when you connect the actual circuit to PC.

noie said...

Sir, is it applicable to PIC 16877A??

Unknown said...

Hello dharmani

Your blog is pretty good.

This is very useful project for me.

I tried to to download but the link is not working.

Can you refresh the link or send me all the files?

My e-mail : emrah3535@gmail.com

Thank you very much.

CC Dharmani said...

Hi Emrah,

I checked, the download links are working. But anyways, I'm sending the files to your email address!

Anonymous said...

Hai Dharmani,
I am gokulraj. I am using rtc1307 interfaced with at89c52 controller. I have a problem of displaying the garbage values. When i start the simulation the rtc will set accordingly and it will run well. But after few seconds it will display the garbage the values in lcd display as well as in the rtc time displaying window..... Pls help me to resolve this problem...

Thanks in advance.

zur said...

I can't find configuration Fuse
please send me.
best regards.

Anonymous said...

can i do this i2c interfcng using atmega32 ???

Anonymous said...

what hardware components are required if i just have universal programmer wid me?

Unknown said...

Hi Dharmani, your project is very helpful. Please send me all the supporting files to abhijeet.tawar007@gmail.com. Thank You.

Anonymous said...

HELLO SIR '; please can you send me
all files @ vermashailendra403@gmail.com

vrushali said...

Hi Dharmani, i trying to convert this
"Interfacing RTC & serial EEPROM using i2c bus, with ATmega128 uC" code into atmega32, i have modified the code but still i m not getting output in proteus. so please can u help me with this ? can u send me the modified code of atmega32 nd proteus file too ?

vrushali said...

And my email id is hva12@entc.maepune.ac.in
-->Vrushali

tazi said...

hi sir i have tried this code on atmega16 ..but it shows error....plz send me the modified code for atmega 16...my email-tazmin18@gmail.com

Unknown said...

Could anybody tell me what changes to make in the header file to make it work with atmega32 ?

Dorian said...

Hi!

It`s a very nice project!! I`m creating something very similar but I`m kinda stock in how to know the address of each device. I'm connecting an Arduino328 (master), a PIC12F675 (slave)an EEPROM and a RTC but I don't know how to get the Address of the last two ones.

I would really appreciate your help! My email is msn at dorianmtz.com

Thank you in advance!

Sandeep_Singh said...

@Dorian you can get address of the device from their datasheet.
For RTC(DS1307) it is 0xD0 and for EEPROM (24LC128) it is 0xA0 provided that you connect A0,A1,A2 pins of EEPROM to ground. you should change the last bit according to your operation whether it is a read(1) or write(0).
reply if you need any other help: Sandeepsinghdeora1994 at gmail.com

sasi said...

hai sir,

this is sasi. i am using Atmega128 interfacing with EEPROM 24LC512. I am using Codevision AVR compiler. i need to adapt your AVR Studio project file to codevision AVR c code. please send me project file in codevision AVR to sasirekaece@gmail.com

Thanks,
sasi

Unknown said...

hi sir, i want reference code to write my own eeprom accessing code, and i am using Atmega2560 (Not arduino) and i have i2c attach files, please can you send me a reference links : sanjisrinivas@gmail.com

TIMA said...

Mr CC Dharmani please I need your help
I try to do your project but it does executed I use ImageCraft ICCV8 for AVR it told that he has problem with library waht can I do
PlEAAAAAAASe help me

Bollywood Baatein said...

Hi Dharmani sir, i want to try your project, would you please me the complete files to vaswanipratik@gmail.com,,,,,

PLC Training in Chennai said...

thanks for sharing this

Bakhtiar said...

Dear Concern,
I a hobbyist. So i am interested to make a sample project . which is below:
1.writing variable length floating value in atmega32 internal eeprom.
2.reading that value and display it in LM044L LCD. now if power is off in mc. after that it will again display that previous saved

value.

Please tell your suggestion.
Awaiting for your reply.

Anonymous said...

hello,
Thanks for the great work your doing. I have one question from the file EEPROM_routines.c

while((data = receiveByte()) != 0x0d)
{
transmitByte(data);
if(data == 0x0d)
transmitByte(0x0a);
errorStatus = i2c_sendData(data);
if(errorStatus == 1)
{
transmitString_F(PSTR("EEPROM write data failed.."));
i2c_stop();
return(1);
}
}

What to the lines above do especially:

- why do you use the condition ((data = receiveByte()) != 0x0d) in the while, what are you trying to do

From that section I figure your trying to read each character being entered from the terminal but i've not yet figured out how your doing it.

Anonymous said...

Also, why do you transmit the data received back to the computer:
while((data = receiveByte()) != 0x0d)
{
transmitByte(data);

Unknown said...

HI,
I think i get the code now
the condition ((data = receiveByte()) != 0x0d) in the while is checking if the data user pressed the enter key

the
data = receiveByte(); transmitByte(data);
is transmitting the data received so that it can be echoed on the terminal


Thanks again for the good work

Unknown said...

Hello sir, I am prajwala. I will like to do thise project can you please send me deatiled code and information of this project
Emial id- prajwaladedoe@gmail.com

chandrasekar said...

hi sir , this is chandrasekar
can you please send me Lcd_routines for the above project.

mail id : chandrasekar.79@gmail.com

your postings are really good.

thank you.

chandrasekar said...

hi sir , this is chandrasekar
can you please send me Lcd_routines for the above project.

mail id : chandrasekar.79@gmail.com

your postings are really good.

thank you.

pdfbama said...

PdfBama PdfBama website serves as a reference for downloading academic books, articles and pamphlets and student projects.

prozhepro said...

دانلود رایگان کتاب تفسیر موضوعی قرآن علی نصیری pdf

کتاب تفسیر موضوعی قرآن علی نصیری pdf

prozhecart said...

پروژه کارت
حقوق فضای مجازی pdf

shane said...

Dharmanitech is an innovation blog giving quick data and updates about different parts of innovation, including devices, programming, and industry patterns. With an emphasis on demystifying complex tech points, this blog plans to make innovation open and separation before divorce reasonable for perusers. Whether you're a tech devotee or searching for down to earth tech exhortation, Dharmanitech offers an important asset for tech-related bits of knowledge and direction cuanto cuesta un abogado de divorcio en new jersey.

Blue Yonder Corp said...

Processing payments for medical services can be made easier and more convenient with the use of Medical Credit Card Processing. This innovative solution allows healthcare providers to securely accept payments from patients using their credit cards. By implementing this system, medical practices can streamline their payment processes, reduce administrative tasks, and improve overall patient satisfaction.

mathewjoy said...


"Design with Microcontrollers" is an invaluable resource that demystifies the world of microcontroller-based design. The book combines comprehensive insights with practical examples, making it accessible for both beginners and experienced engineers. With a focus on real-world applications, it guides readers through the intricacies of microcontroller programming and interfacing. Theseguro dui clear and concise explanations, coupled with hands-on projects, ensure a holistic learning experience. Whether you're diving into embedded systems or looking to enhance your skills, "Design with Microcontrollers" stands out as an essential guide in the realm of electronic design.