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 - an apology and a request.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
La[bRat]
Guest







I2C - an apology and a request.
PostPosted: Sun Apr 09, 2006 9:42 am     Reply with quote

First, I'd like to apologise for creating yet another thread on I2C problems, but feel like I have trawled the entire internet and I still can't make head nor tail of this 'little' problem...

I'm trying to make two a TI DSP and a pic talk. No, talk isn't even the right word. The DSP is going to periodically throw out two 8bit integers, and all the PIC has to do is listen. The only communications protocol that PIC and DSP share are I2C.

Now, I've created a test rig using a 16f84A as a master and 16f877A as the slave. In the real device (if it doesn't get thrown out of the window first) I shall keep the '877A as the slave, and replace the '84A with the DSP. However, I need to get it working first!

I have tried everything - the examples in the example directory (ex_slave.c), examples posted on t'interweb, and as many permutations of mine own code that I can write but my PIC is still not receiving any data! I've been watching the scope traces, and as soon as the slave has received the address signal it carries on with the program, and ignores any data that follows. Any calls of I2c_read() return the address and nothing else. This happens on programs that have been PROVEN to work with other PICs. What am I doing wrong?

I've been trying to use the built-in functions provided by CCS since I don't have the time to mess about with 'bit banging', but I've noticed that although the '877A *does* have built in support for I2C that compiler doesn't seem to use it - specifying 'FORCE_HW' or 'NOFORCE_SW' produces idential code to using nothing at all (ie. software mode)!

Is it the '877A? Should I be using a different PIC? Should I give up and try to use some other form of communication? Any suggestions / ideas would be gratefully received - after 6 days straight I'm starting to get a little frustrated!

Many thanks...
Ttelmah
Guest







PostPosted: Mon Apr 10, 2006 5:07 am     Reply with quote

What compiler version?.
What is your 'USE_I2C' line on the slave?.
The only reason normally for 'force_hw' not to work, is using the wrong pins for I2C. The line for your processor should be:

#USE_I2C (SLAVE, SCL=PIN_C3, SDA=PIN_C4,ADDRESS=0xA0,FORCE_HW)

Remember that the address must be 'read' by the slave, before another byte can be sent. Are you driving the code in an interrupt routine, or in a loop?. If the former in particular, there needs to be a significant delay in the master, to allow time for the slave to enter the interrupt routine, and read the byte(s), before sending anything else.
I'd suspect possibly that SSPOV is getting set. This will happen if a subsequent byte arrives _before_ the slave has read the byte. Once this happens, the hardware will set the SSPOV bit, and stop transferring bytes from the input buffer to the read register, which is exactly what you describe. Remember that the slave, only 'sees' the byte, when the transfer is complete (last bit sent).

Best Wishes
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