View previous topic :: View next topic |
Author |
Message |
Bart
Joined: 12 Jul 2005 Posts: 49
|
The working of SPI : where to find it ? |
Posted: Tue Oct 18, 2005 2:05 pm |
|
|
Hello,
Can I somewhere find an explanation of the SPI bus ?
I tryed already the manual and looked already to a lot of examples but I can't still understand a simple program as the one you can see here.
http://www.ccsinfo.com/forum/viewtopic.php?t=23183&postdays=0&postorder=asc&highlight=mmc+write&start=15
More in particular :
this : where are the values 13 14 94 comming from ?
Code: |
#byte SSPBUF = 0x13
#byte SSPCON = 0x14
#byte SSPSTAT = 0x94
#bit BF = SSPSTAT.0
#bit SMP = SSPSTAT.7
#bit CKE = SSPSTAT.6
#bit CKP = SSPCON.4
#bit SSPM1 = SSPCON.1
#bit SSPEN = SSPCON.5
|
and this : how can BF change ?
Code: |
char SPI(char d)
{
SSPBUF=d;
while (!BF);
return SSPBUF;
} |
I think I need some general info on SPI or maybe above program with more explanating.
If someone could re-take above program with some more remarks at the lines, it would help me a lot.
Thanks for the willing people. _________________ I like Skype (www.skype.com), my username is BplotM |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
|
Ttelmah Guest
|
|
Posted: Tue Oct 18, 2005 2:53 pm |
|
|
And the chip data sheet.
The numbers in the byte defines, are the addresses in the chip of the hardware for SPI. 'BF', is then the buffer full flag, which changes when the byte is clocked in/out. The values posted are for the 16 family chips.
Best Wishes |
|
|
Bart
Joined: 12 Jul 2005 Posts: 49
|
|
Posted: Tue Oct 18, 2005 3:28 pm |
|
|
@dyeatman
Thanks. Didn't know you could connect more devices at the same 3 wires with different CS line.
@Ttelmah
Thanks. All details seems to be in the data sheet, as you sayed.
I looked in the CCS manual. Couln't find much there.
So this means that
SSPBUF
SSPCON
SSPSTAT
are "reserved" byte names for the CCS compiler ?
So with : "SSPBUF=d;" you put somethings (char d in this case) out on the lines ?
Thanks. _________________ I like Skype (www.skype.com), my username is BplotM |
|
|
|