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.

Problem with I2C code for DS1307RTC on Real Simulator

Status
Not open for further replies.

dayanpad

Advanced Member level 4
Joined
Mar 23, 2009
Messages
114
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Location
Colombo
Activity points
1,921
Dear All please assist

following codes for DS1307RTC
it does not work with Real Simulator
MCU is 16f877

void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
PORTB = 0;
TRISB = 0; // Configure PORTB as output

I2C1_Init(100000); // initialize I2C communication

I2C1_Start(); // issue I2C start signal
I2C1_Wr(00); // send byte via I2C (device address + W) device address as per real pic simulator
I2C1_Wr(3); // send byte (data address)
I2C1_Repeated_Start(); // issue I2C signal repeated start
I2C1_Wr(00); // send byte (device address + R)
PORTB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop();

above codes using mikroC pro for PIC compiler

you can download real pic simulator following link
https://digitalelectrosoft.com/download/RealPicSimulator.exe
 
Last edited:

Re: I2C and simulator

Your second I2C1_Wr(00) should be I2C1_Wr(1) in order to set the R bit. Are the device addresses correct? I've never seen a 0 address in any I2C device before.
 

Re: I2C and simulator

Are the device addresses correct?
I would expect the DS1307 addresses 0xd0/0xd1 here. Is your simulator able to simulate the DS1307 as I2c peripheral?
 

Re: I2C and simulator

Dear FvM,
Thanks for reply
this DS1307 address define by real pic simulate. this is not actual address of DS1307
please try to download the link that I show above (Real pic Simulator)
 

Re: I2C and simulator

It' looks to me like a simulator problem, but don't use mikroC and thus can't further check the behaviour of your code.
 

Re: I2C and simulator

I suggest you give up on the simulator and use the real hardware. Ultimately, you'll end up chasing real problems as opposed to simulator bugs. It's much more satisfying to solve real-world problems. ;-)

You'll need to use the addresses as pointed out by FvM. Commentary: Probably the worst disservice we do to students is make them think that simulators are the same as the real world. Basically, they double your work load because you not only need to understand the simulator (and all its deficiencies or bugs) but then also need to test the design with real hardware. (I do use simulators for things like power supply analysis but, based on what I've seen on this board, most LCD and device simulators seem to have their share of bugs.)
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top