Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I2C interfacing with 8051

Status
Not open for further replies.

nikhil0802

Newbie level 1
Newbie level 1
Joined
Aug 7, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
9
how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 ic. and i want to know how do i code it in c to interface it.
 

Just do a Google search! There are libraries and applications notes around.

Peter
 

Just read the datasheet of DS1307. There will be details given about the i2c read and write cycles along with timing details. Just write code for those.

Eg: write individual functions for i2c_ack, i2c_start, i2c_stop etc... Then according to the flow given in the datasheet make a different function which will call all these functions in that order with the appropriate data being passed.
 

how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 IC. and i want to know how do i code it in c to interface it.

First you have to write I2C routines like I2c start, I2c Stop, I2C_Acknowledge_wait, I2C_Byte_Read, I2C_Byte_Write,
these are sub functions of I2C and deals with your SDA and SCL line.

Then try to write the Peripheral IC sub routine function using the I2C sub functions. e.g. Read_DS1307, Write_Ds1307,
Which will write and read the data from DS1307.
 

how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 ic. and i want to know how do i code it in c to interface it.

See some examples:

Real Time Clock Interfacing (DS1307) with AT89S51
https://www.8051projects.info/resources/real-time-clock-interfacing-ds1307-with-at89s51.50/

Interfacing of Real time clock DS1307
**broken link removed**

Digital Clock with alarm using DS1307
**broken link removed**



Existing thread:
https://www.edaboard.com/threads/130813/



Best regards,
Peter
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top