View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 09, 2010 1:31 am |
|
|
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
|
|
Posted: Thu Dec 09, 2010 6:21 am |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Thu Dec 09, 2010 6:44 am |
|
|
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
|
|
Posted: Sat Jul 02, 2011 10:19 am |
|
|
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 ... |
|
|
|