CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

i2c one master 2 slaves

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 1:31 am     Reply with quote

Quote:
#include <18f452.h>

#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3)

Using the XT fuse with a 20 MHz crystal, tells me that you're running
this in Proteus. I don't think Proteus cares about using the correct
oscillator fuse.

But Proteus simply cannot be trusted to work for every situation.
Here is a thread, where he has to upgrade to Proteus vs. 7.6
to make an i2c slave project work correctly:
http://www.ccsinfo.com/forum/viewtopic.php?t=32368&start=36
Oblivion



Joined: 23 Sep 2010
Posts: 13

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 6:21 am     Reply with quote

Quote:
But Proteus simply cannot be trusted to work for every situation.
Here is a thread, where he has to upgrade to Proteus vs. 7.6
to make an i2c slave project work correctly:
http://www.ccsinfo.com/forum/viewtopic.php?t=32368&start=36


I am using v7.7 but you're right. Proteus cannot be trusted.

But can you see any mistakes on my codes? I hope i'm mistaking something in software. Are there any suggestions you can give to me?
temtronic



Joined: 01 Jul 2010
Posts: 9136
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 6:44 am     Reply with quote

get RID of Proteus !!!
It is NOT the Real World !!
Sorry for sounding like a broken record , but this is yet another reason why I do NOT use Proteus or any other simulator.
They do NOT work 100% like hardware.

Maybe this forum needs another folder for just Proteus users...
or.. a fill in the blank form that has PIC type, CCS version, voltages, real or simulation' fields....

It would be helpful in the future to state you're using Proteus or real hardware, so old guys like me that only use real hardware don't bother with stupid simulation software that is impossible to debug and fix.

Btw the mistake in your software is inside Proteus.
plainas1234



Joined: 28 Jun 2011
Posts: 3
Location: Anadia

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 10:19 am     Reply with quote

Staff now thank you for sharing your knowledge in the forum, I'm making a project that involves many analog inputs and so I will use three microcontrollers, up to this code works already, but I'd like to know if you can send a pic slave two 8-bit data that is two bytes and receive the master with 2 i2c_read I've tried this but when I stop the slave pic. I am doing testing on real hardware.

Example of code that did:

code master -> read slave1:
Code:

void i2c_first (){
   i2c_start();
   i2c_write(SLAVE1_READ_ADDR);
   delay_ms(100);
   data1=i2c_read();
   data3=i2c_read();    // ->>  change that caused errors
   end=i2c_read(0);
   i2c_stop();

code slave -> send master:

void i2c_first (){
   i2c_start();
   i2c_write(SLAVE1_READ_ADDR);
   delay_ms(100);
   data1=i2c_read();
   data3=i2c_read();    // ->> change that caused errors
   end=i2c_read(0);
   i2c_stop();
   delay_ms(100);
}
   delay_ms(100);
}


I would appreciate a response because this project is very important to me.
Thank you for your attention ...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group