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

SPI on PIC10F222

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








SPI on PIC10F222
PostPosted: Fri Oct 03, 2008 9:36 am     Reply with quote

Hello, can I use SPI protocol in a PIC10F222?. I know this protocol is not implemented in the PIC10F222 by hardware, but can be implemented by software using CCS?

Thanks.
sephirot82



Joined: 03 Oct 2008
Posts: 2

View user's profile Send private message

PostPosted: Fri Oct 03, 2008 9:41 am     Reply with quote

Hello again, I'm sephirot82, in the previous post was not registered yet.
Ttelmah
Guest







PostPosted: Fri Oct 03, 2008 10:01 am     Reply with quote

Answer. Yes, as a master.
As with I2C, implementing a slave, really requires the hardware.
The compiler needs to be reasonably 'recent'. Software SPI, is only implemented 'out of the box', on V4 compilers.

Best Wishes
sephirot82



Joined: 03 Oct 2008
Posts: 2

View user's profile Send private message

PostPosted: Fri Oct 03, 2008 10:09 am     Reply with quote

Thank you for your reply. Where can I find an example of this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 03, 2008 11:59 am     Reply with quote

Software SPI examples:

Using the shift_left() function:
Quote:
c:\program files\picc\drivers\25160.c
c:\program files\picc\drivers\25640.c
c:\program files\picc\drivers\ad7715.c
c:\program files\picc\drivers\ads8320.c
c:\program files\picc\drivers\ds1868.c
c:\program files\picc\drivers\can-mcp2510.c

There are tons of them. Use a text search utility program such as
Examine32, and have it search the CCS Drivers and Examples
directories for this search string:
Quote:
shift_left


For the new #use spi() statement, there is only one example or driver
file, but it uses hardware SPI. #use spi() has the capability to do software SPI.
Quote:
c:\program files\picc\drivers\mmcsd.c

You will have to search the forum for more examples. Also, the forum
articles contain info on problems with #use spi().
Guest








PostPosted: Sat Oct 04, 2008 5:29 pm     Reply with quote

Hello again, I have some doubts about this protocol and CCS. In this case, the PIC10F222 has no SPI, but it can be implemented by software, using the shift_left() function, but if I use another PIC that has SPI, how is the program? Was also used the shift_left() function or is it easier? What's the difference? I am a rookie at this, but I want to have it clear before continuing.

Note: I try to write English as well as possible, apologies if there are errors.

Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 04, 2008 5:39 pm     Reply with quote

If the PIC has hardware SPI capability, then you can use the CCS
functions for hardware SPI:
Quote:
setup_spi()
spi_write()
spi_read()
and others.


A PIC with hardware SPI will have pins with these labels. Look in the
PIC data sheet to see this:
Quote:

SCK
SDO
SDI
\SS


This CCS driver file uses hardware SPI:
Quote:
c:\program files\picc\drivers\9356spi.c


To find more sample code for hardware SPI, search this forum for:
Quote:
setup_spi

Here is a link to the search page:
http://www.ccsinfo.com/forum/search.php
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