 |
 |
| View previous topic :: View next topic |
| Author |
Message |
RVR
Joined: 04 Jan 2012 Posts: 18
|
|
Posted: Thu Oct 25, 2012 8:45 am |
|
|
Thanks for yours answers Ttelmah and Jeremiah,
| Quote: | | First, get rid of the speed setting in the slave. |
Ok, done. but the problem still happens.
| Quote: | | Second, have you tried using the old standard syntax for the read on state 80 |
yes, and the problem still happens (using i2c read())
| Quote: | | Also, have you checked the errata for the part to make sure there are no I2C issues with that particular chip? I run into a few in the past. |
No, i dont know where looking could you help me ? |
|
 |
jeremiah
Joined: 20 Jul 2010 Posts: 1426
|
|
Posted: Thu Oct 25, 2012 5:54 pm |
|
|
| The easiest way is to simply go to the Microchip website and find the webpage for your particular chip. One of the documents is usually titled something like Silicon Errata in the title and will list various issues with different versions of your chip. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Fri Oct 26, 2012 1:39 am |
|
|
Key thing is to type the chip name into the field for 'search site', _not_ the field for 'search data sheets'. Stupidly, Microchip have changed things so the latter does not find errata. Using the top search, the first response should take you to the page for this chip, and the field for 'documents' in this will then list the errata.
If I remember (quick look in my archive), there are actually three errata sheets for this chip, and some are dozens of pages long, with several pages on the MSSP. 90% of the MSSP problems are with SPI, but there are perhaps half a dozen for the I2C. Most won't give this problem (oddities with timings etc.). There is one really annoying one that if you get it is hard to work round, to do with the way the chip initialises - since CCS does the initialisation for you, it is quite hard to implement the work round. However this one only seems to appear on some chips/boards. I didn't bother to look for ones for 'slave' (was only using master), but remember there being a few....
One thing worth trying, would be to define the CKP pin:
#bit CKP=("BIT:CKP")
and set this high as the last thing in the ISR. This will _ensure_ it is released, even if CCS is missing it, or there is some timing peculiarity with it.
Best Wishes |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Fri Oct 26, 2012 2:44 am |
|
|
Just gone and browsed the sheets. There are several that have potential problems....
The two I remembered (about clock stretching), are:
"When configured for I2C™ slave reception, the
MSSP module may not receive the correct data, in
extremely rare cases. This occurs only if the Serial
Receive/Transmit Buffer Register (SSPBUF) is not
read after the SSPIF interrupt (PIR1<3>) has
occurred, but before the first rising clock edge of
the next byte being received.
Work around
The issue can be resolved in either of these ways:
• Prior to the I2C slave reception, enable the
clock stretching feature.
This is done by setting the SEN bit
(SSPCON2<0>).
• Each time the SSPIF is set, read the SSPBUF
before the first rising clock edge of the next byte
being received."
So, this one needs you really to enable clock stretching, or ensure that you have read the byte before the next one starts, but is followed with:
"When in I2C Master mode, if the slave performs
clock stretching, the first clock pulse after the slave
releases the SCL line may be narrower than the
configured clock width. This may result in the slave
missing the first clock in the next transmission/
reception.
Work around
The clock pulse will be the normal width if the slave
does not perform clock stretching."
So this one could give data loss if clock stretching is used....
Now, my immediate 'thought' here, would be to try disabling clock stretching, but to add a delay in the master, and make it long enough to _ensure_ the slave has read the byte even without clock stretching.
Since it takes about 50 instructions to get into the ISR, and decide what to do, then another 30 instructions to exit the ISR, and be ready for the next event, something like:
delay_cycles(80); between the I2C transmissions, and setting 'NO_STRETCH' in the slave, should avoid this.
The other ones that might be applying, are the one regarding SSPOV getting set, if a byte in the transmitted data, matches the slave address (I'd add a line to clear this bit at the end of the ISR), and the one about the module not initialising properly (this was the one that affected me), but this didn't give the effects being seen here.
The others about baud rates etc., shouldn't really cause this problem either....
Best Wishes |
|
 |
|
|
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
|