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 PIC Slave at 8MHz and PIC Master at 48MHz
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

I2C PIC Slave at 8MHz and PIC Master at 48MHz
PostPosted: Sun Feb 10, 2008 9:44 pm     Reply with quote

I am using two PICs in a Master/Slave pair. The clock differences are as listed in the title. The writes from master to slave work well as long as the slave is fully running before the master is released from reset. If not, the slave catches the first state == 1 of the i2c_isr_state (address) but never sees state == 2 (data). I am using the samples from EX_SLAVE and EX_EXTEE for code so I won't post those now. Any idea if the large clock differences could be playing a part? Is there any simple way to resynch these two or clear the slave to get back on track?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 10, 2008 10:19 pm     Reply with quote

Here's something to try. Have the master call the get_ack_status()
routine in the following post. Give it the i2c write address of the slave
as the parameter. Wait until you get an 'ack' back from the slave before
you proceed with your normal i2c code.
http://www.ccsinfo.com/forum/viewtopic.php?t=32753&start=11
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 7:35 am     Reply with quote

Thanks. I'll try that tonight.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 5:22 pm     Reply with quote

No success. The master continues to write, slave_address, data_address and data, but the slave never sees state == 2 for the data value. I put a long delay at the beginning of the master boot up to ensure the slave is always ready and that solves the problem, ugly for now. Seems like an out of synch issue I should be able to clear on the slave side.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 6:54 pm     Reply with quote

I remember a thread a few months ago where they had a lot of problems with the I2C clock at higher speeds.

Please post:
- The I2C clock speed you are using.
- The type number of your sending and receiving PICs, including the silicon revision number.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 6:58 pm     Reply with quote

Slave PIC is 16F887-E
Master PIC is 18F4550-I or "1" can't tell with my old eyes Smile

I have them both set for SLOW in there #use i2c statements.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 7:55 pm     Reply with quote

The silicon revision level is a code not printed on the chip package. Some programmers or an In-circuit debugger like the ICD2 show you the silicon revision code when connecting (looks like A3 or B5 or ...).

It seems like the 16F887 is still at it's first revision because I can only find one errata document: http://ww1.microchip.com/downloads/en/DeviceDoc/80302D.pdf.
There is a bug when using this chip as an I2C slave which I don't think is handled by the compiler. Please check Issue 5 of the above document.

For the PIC18F4550 the A3 revision has many issues, some affecting an I2C master. The newer B4, B5 and B6 steppings look ok.

What is your compiler version number?
In the v4 compilers you can specify the exact I2C speed. It would be worth a shot to try a slower frequency and / or check the clock signal with a scope.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 8:10 pm     Reply with quote

I suppose I can't see the silicon rev with the ICD-U40?
I'm using 4.068 but don't have a scope at home to check the waveform.
I'll look at the errata on the 16F887 and the work around.
I don't seem to find what the SLOW setting for I2C relates to unless it is the 100KHz standard.
I'll also try setting a slower I2C bus speed.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 8:22 pm     Reply with quote

Quote:
I suppose I can't see the silicon rev with the ICD-U40?
It should be possible but I never used that device. It's something like reading an address but my ICD2 under MPLAB shows the revision everytime I connect so I never figured out how to do it otherwise.

Quote:
I don't seem to find what the SLOW setting for I2C relates to unless it is the 100KHz standard.
Slow = 100kHz, Fast=400kHz.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 9:32 pm     Reply with quote

This post has code read the Device ID and silicon revision:
http://www.ccsinfo.com/forum/viewtopic.php?t=20257
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 9:36 pm     Reply with quote

Thanks for the code:

18F4550 Device ID: 1202

16F887 Device ID: 2082

I'll have to interpret these tomorrow.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Tue Feb 12, 2008 8:36 am     Reply with quote

From the Device ID registers it appears both of these are silicon revision 2. I need to see if this makes any sense with the errata listings.
KD5UZZ_
Guest







PostPosted: Tue Feb 12, 2008 9:57 am     Reply with quote

In one of your posts you say that you have them both set to 'slow'. I thought you only 'set' the master's I2C speed, and the other follows it.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

PostPosted: Tue Feb 12, 2008 10:34 am     Reply with quote

I didn't find any issue in the manual nor did I get any type of error or warning during compile so I left it there for now. I had listed it origionally hoping some compatibility problem was causing the lock-up.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Feb 12, 2008 5:13 pm     Reply with quote

bwhiten wrote:
From the Device ID registers it appears both of these are silicon revision 2. I need to see if this makes any sense with the errata listings.
Have you checked the Errata manuals?
PIC18F4550 with chip revision ID number 0x02 translates to revision A3 Silicon. I have no clue as to why Microchip has two numbering schemes, but I got this information from the top of the Silicon A3 Errata document.

The A3 revision has a lot of problems !!! Of the 30 known problems only item 17 could be a partial explanation of your I2C problems. See if you can get one of the newer chips, for example the B4 stepping has only 7 listed problems (although be warned Microchip is slow in adding new errata).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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