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 CCS Technical Support

I2C routines on PICs that don't have I2C built-in...?

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







I2C routines on PICs that don't have I2C built-in...?
PostPosted: Tue Jun 07, 2005 7:22 am     Reply with quote

Has anybody used the built-in I2C routines (e.g. I2C_POLL(), I2C_READ())on PICs that do not have dedicated I2C pins?

According to the PCW manual, the I2C_POLL() and I2C_READ() routines are only available on devices that have built-in I2C. I would like to use the I2C routines on a 16F648A which does not have built in I2C...

Thanks,
Spero.
Ttelmah
Guest







PostPosted: Tue Jun 07, 2005 7:50 am     Reply with quote

What do you actually want to do with I2C?.
The internal routines work fine to implement a _master_ in software. What they cannot do, is implement a slave. I2C_POLL cannot work, because without the hardware, there is no buffer to look at the status of. I2C_READ, also works fine _in master mode_. Again what cannot be done is to implement a slave, where a byte is automatically received and clocked into a buffer. Potentially a slave would perhaps be 'writable', but would require the use of other hardware resources (using an interrupt pin to control the transfer), at the very least, and as such would not be generic code.
So you can control an I2C peripheral, send it clocks, send it data, and read back it's replies fine with the supplied code, using software. If you need a slave, then I'm afraid it would be down to writing custom code yourself.

Best Wishes
valemike
Guest







PostPosted: Tue Jun 07, 2005 9:03 am     Reply with quote

Ttelmah wrote:
If you need a slave, then I'm afraid it would be down to writing custom code yourself.


In fact, i think writing custom code might not be too feasible either, unless you resort to a very high frequency of polling. You definitely need the MSSP interrupts that tell you a buffer is full.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 07, 2005 9:13 am     Reply with quote

valemike wrote:
Ttelmah wrote:
If you need a slave, then I'm afraid it would be down to writing custom code yourself.


In fact, i think writing custom code might not be too feasible either, unless you resort to a very high frequency of polling. You definitely need the MSSP interrupts that tell you a buffer is full.


You would want to use an external interrupt to detect the start condition. This would allow you to for go the high polling.
Ttelmah
Guest







PostPosted: Tue Jun 07, 2005 3:48 pm     Reply with quote

Yes. The problem actually is not really the polling interval, but the long latency on entering an interrupt. I'd suspect it could be done fairly easily for 'slow' I2C transfers, especially on the faster chips, but it is going to interfere with just about everything else while the transfer takes place...

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jun 08, 2005 6:30 am     Reply with quote

I have never tried this before, but several other Micro manufacturers insisted they could do a slave in firmware. SSP slave is a sticking point for us. I always doubted how well it would work as far as speed but if you are controlling the master as well, then you should be able to make it work. I'd just choose another micro that has one though.
Ttelmah
Guest







PostPosted: Wed Jun 08, 2005 4:01 pm     Reply with quote

The PIC has enough trouble managing a SSP slave in hardware!. The latency on the interrupt response, really does mean the master has to be aware of just how slow the device will be on receiving the first byte. The actual transfers should be fairly easy, provided you are a little flexible about the actual sampling 'point', and the rate is low enough to allow a good number of instructions/bit...

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