View previous topic :: View next topic |
Author |
Message |
Guest
|
SPI on PIC10F222 |
Posted: Fri Oct 03, 2008 9:36 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
sephirot82
Joined: 03 Oct 2008 Posts: 2
|
|
Posted: Fri Oct 03, 2008 9:41 am |
|
|
Hello again, I'm sephirot82, in the previous post was not registered yet. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Oct 03, 2008 10:01 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
sephirot82
Joined: 03 Oct 2008 Posts: 2
|
|
Posted: Fri Oct 03, 2008 10:09 am |
|
|
Thank you for your reply. Where can I find an example of this? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 03, 2008 11:59 am |
|
|
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:
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(). |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sat Oct 04, 2008 5:29 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Oct 04, 2008 5:39 pm |
|
|
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:
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:
Here is a link to the search page:
http://www.ccsinfo.com/forum/search.php |
|
![](templates/subSilver/images/spacer.gif) |
|