• AVR Freaks

Hot!TWo PIC 18f4620 , one as master & the second is slave I2C communication problem

Page: << < ..6789 > Showing page 6 of 9
Author
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:06:29 (permalink)
0
DarioG
ubuntuman
 
He says to put 0x18 in master and 0x18 in slave not 0x30 in master and 0x18 in slave 




Yep, while we say put 0x30 in master and 0x18 in slave :)


i know . i just explain to rodims
rodims
Super Member
  • Total Posts : 1491
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:07:10 (permalink)
+2 (4)
ubuntumanDo u see this in the screenshot i post above or u see this only in the screenshot of the "not ackwonledge" signal ? 
                                            hell NO

Please don't shout :-)
No I do not see any problem there. How should I ? The only relevant information from your citation is
"the SDA pin must remain stable for that duration and some hold time after the next falling edge of SCL."
Why do you think that this is not the case ?
I think you misinterprete something and as I said, I do not see that this discussion will help you to resolve your real problem. I think you should follow Dario's proposal and use a real hardware. You must debug your master and slave separately, not both at the same time. That's the best tip I can give.
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:09:14 (permalink)
0

17.4.10 I2C MASTER MODE TRANSMISSION
The data on
the SDA pin must remain stable for that duration and
some hold time after the next falling edge of SCL. After
the eighth bit is shifted out (the falling edge of the eighth
clock), the BF flag is cleared and the master releases
SDA.

this first screen for the "not ack" signal https://imgur.com/T8R74GL
 
this screen for one of the data signal https://imgur.com/HcRLZ1a
 
 Do u see this in the screenshot i post above or u see this only in the screenshot of the "not ackwonledge" signal ? 
                                              NOOOOOOOOOO 
so does any one else see that the I2C hardware is sending the bits in right form or am i blind ? !!!!!!
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:11:10 (permalink)
0
Why do you think that this is not the case ? 

check the screenshots and u will see that it is not the case 
rodims
Super Member
  • Total Posts : 1491
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:13:26 (permalink)
+2 (4)
Ok, this one is really the last one.
ubuntumanHe says to put 0x18 in master and 0x18 in slave not 0x30 in master and 0x18 in slave

Jerry never said that. He said:
If your master is sending 0x30 as the slave address (R/W_ = 0), then load 0x30 into the slave SSPADD reg

And it's not the number I'm talking about, - the bold text is the relevant part. Over and out :-)
rodims
Super Member
  • Total Posts : 1491
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:14:39 (permalink)
+3 (3)
Thank you for thumbs down :-)
 
Jerry Messina
Super Member
  • Total Posts : 389
  • Reward points : 0
  • Joined: 2003/11/07 12:35:12
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:14:54 (permalink)
+2 (2)
I'm saying you put the entire 8-bit byte that the master is going to transmit into the SSPADD register.
If the master sends 0x30 that's a write address and 0x31 is a read address... there's no additional R/W bits added on the master side. Bits 7-1 hold the 7-bit I2C address and bit 0=R/W_
 
Then, load 0x30 into the slave SSPADD register. That's always worked for me.
 
In I2C terms that's address 0x18 (since they usually ignore bit0 when talking about the 7-bit address). I never load or send 0x18 anywhere.
 
 
 
 
post edited by Jerry Messina - 2017/11/14 05:17:31
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:17:43 (permalink)
+1 (1)
Now I took a look at a PIC18 datasheet, and it says "load full shifted address into SSPADD and LSB is don't care" !
 
So, well, we both were right.
Funny that Microchip did that, but it happens.
Excuse us, Ubuntuman :)

GENOVA :D :D ! GODO
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:20:50 (permalink)
+1 (1)
So much confusion in one thread.
Jerry is talking about what has to be written to the register, but the OP is calling a MikroC library function to do it, which muddies the water.
 
The OP is jumping up and down about some anomalies seen on the trace in the simulator.
Total waste of time. Simulators are never 100% accurate. If you see something wrong in the simulator, it's probably a bug in the simulator.
 
Same with mucking around the the GC flag. You're just going to find problems with the GC implementation, which does not help at all with the original problem.
 
As others have already mentioned, trying to test a "not known to work" Master with a "not known to work" Slave is a pointless exercise.
You need at least one thing that is known to work to test your code.
 
 
 
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:21:04 (permalink)
0
rodims
Thank you for thumbs down :-)
 


U are welcome Dear 
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:23:16 (permalink)
+1 (1)
qhb
So much confusion in one thread.
 




Yeah, but at least I learnt something (that discrepancy above) about I2C modules Smile
(of course, I like staying with my SW I2C even more grin )

GENOVA :D :D ! GODO
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:25:09 (permalink)
0
Jerry Messina
I'm saying you put the entire 8-bit byte that the master is going to transmit into the SSPADD register.
If the master sends 0x30 that's a write address and 0x31 is a read address... there's no additional R/W bits added on the master side. Bits 7-1 hold the 7-bit I2C address and bit 0=R/W_
 
Then, load 0x30 into the slave SSPADD register. That's always worked for me.
 
In I2C terms that's address 0x18 (since they usually ignore bit0 when talking about the 7-bit address). I never load or send 0x18 anywhere.
 
 
 
 


what u mean that 0x18 is not to be sent anywhere ? which problem u think in 0x18 it self as a number i didnt get u 
rodims
Super Member
  • Total Posts : 1491
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:26:39 (permalink)
+2 (2)
DarioNow I took a look at a PIC18 datasheet, and it says "load full shifted address into SSPADD and LSB is don't care" !

In this case I also have to excuse, that my PIC24 i2c knowledge cannot be applied to PIC18 and caused additional noise. Thanks for clarification, Jerry. 
Still as you said it does not work with any of the tried address combinations.
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:26:42 (permalink)
+1 (1)
DarioG
Now I took a look at a PIC18 datasheet, and it says "load full shifted address into SSPADD and LSB is don't care" !
 
So, well, we both were right.
Funny that Microchip did that, but it happens.
Excuse us, Ubuntuman :)


Thank u . u tried to help 
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:27:42 (permalink)
0
rodims
DarioNow I took a look at a PIC18 datasheet, and it says "load full shifted address into SSPADD and LSB is don't care" !

In this case I also have to excuse, that my PIC24 i2c knowledge cannot be applied to PIC18 and caused additional noise. Thanks for clarification, Jerry. 
Still as you said it does not work with any of the tried address combinations.


never mind bro just try to listen to me 
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:30:35 (permalink)
0
qhb
So much confusion in one thread.
Jerry is talking about what has to be written to the register, but the OP is calling a MikroC library function to do it, which muddies the water.
 
The OP is jumping up and down about some anomalies seen on the trace in the simulator.
Total waste of time. Simulators are never 100% accurate. If you see something wrong in the simulator, it's probably a bug in the simulator.
 
Same with mucking around the the GC flag. You're just going to find problems with the GC implementation, which does not help at all with the original problem.
 
As others have already mentioned, trying to test a "not known to work" Master with a "not known to work" Slave is a pointless exercise.
You need at least one thing that is known to work to test your code.
 
 
 


U mean that the part of my suspicion in the hardware i2c is not right depending on that the data bit is not staying a while after the clock bit go to 0 ?? and this is bug in simulator ?? 
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:35:51 (permalink)
+1 (1)
ubuntuman
U mean that the part of my suspicion in the hardware i2c is not right depending on that the data bit is not staying a while after the clock bit go to 0 ?? and this is bug in simulator ?? 

Yes. Stop looking for anomalies in the simulator, it's a total waste of time.
It would only be relevant if you were looking at a trace on a real storage scope connected to real hardware.
Jerry Messina
Super Member
  • Total Posts : 389
  • Reward points : 0
  • Joined: 2003/11/07 12:35:12
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 05:45:07 (permalink)
+1 (1)
If you ever try real hardware here's two things to check...

Way back in post #69 there's this:

const unsigned short int crystalOscillator =4000000;      // <<<<<< unsigned short int?
 
void I2C_Master_Init(const unsigned long c)
{
 SSPCON1 = 0b00101000;
 SSPCON2 = 0;
 SSPADD = (crystalOscillator/(4*c))-1;

<snip>
 I2C_Master_Init(100000); //Initialize I2C Master with 100KHz clock

I don't know what the mikroe compiler does with this, but you might want to check what the result of SSPADD for the master clock freq ends up as.

Looking at the schematic, the pullups on SCL and SDA seem to be shown as 10000. If they're really 10K that's a bit high. Might want to try a lower value like 2K-5K
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 09:07:10 (permalink)
0
I changed 
SSPADD = (crystalOscillator/(4*c))-1;
to be
SSPADD = 9;
 

and i put 4.7kohm instead of 10kohm although i think i will make no difference as those two pull up ones are existed just to make sure that the start and stop condition are applied well and SDA or SCL will not start from zero fro instance
BUT nothing changed at the end 
post edited by ubuntuman - 2017/11/14 09:14:12
ubuntuman
Super Member
  • Total Posts : 232
  • Reward points : 0
  • Joined: 2016/05/02 15:28:40
  • Location: 0
  • Status: offline
Re: TWo PIC 18f4620 , one as master & the second is slave I2C communication problem 2017/11/14 09:18:34 (permalink)
0
const unsigned short int crystalOscillator =4000000;      // <<<<<< unsigned short int?


u are absolutely right Jerry . i changed it to unsigned long int 
post edited by ubuntuman - 2017/11/14 09:19:51
Page: << < ..6789 > Showing page 6 of 9
Jump to:
© 2019 APG vNext Commercial Version 4.5