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

The working of SPI : where to find it ?

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



Joined: 12 Jul 2005
Posts: 49

View user's profile Send private message

The working of SPI : where to find it ?
PostPosted: Tue Oct 18, 2005 2:05 pm     Reply with quote

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: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 2:47 pm     Reply with quote

An explanation of SPI can be found here:
http://www.totalphase.com/products/aardvark/specs/?sect=sect1#S1.2

Another is here:
http://www.embedded.com/story/OEG20020124S0116

Another is here:
http://www.mct.net/faq/spi.html
Ttelmah
Guest







PostPosted: Tue Oct 18, 2005 2:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 18, 2005 3:28 pm     Reply with quote

@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
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