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

From SPI to RS232

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



Joined: 28 Apr 2013
Posts: 3

View user's profile Send private message

From SPI to RS232
PostPosted: Tue Apr 30, 2013 5:41 am     Reply with quote

hi friends
I receive data on SPI interface ( 27 bytes to be exact ) and i want to transmit them on the RS232 to PC. How i can do this? It's possible to give me an example ? I'm newbie :D

Thanks a lot
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 30, 2013 6:40 am     Reply with quote

CCS provides examples of both SPI and RS232.
Plus there is loads of relevant code on this forum.

Mike
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 30, 2013 7:44 am     Reply with quote

You didn't give all details, but it is very likely you'll have to add some kind of buffering. On SPI it is very common to have bit rates in the order of Mbits per second where RS232 often stops at 115kbaud.

Search the internet for the concept of a 'ring buffer', it is one powerful method for buffering data. An implementation of the ring buffer in RS232 transmission can be found in the CCS example directory on your computer and is named ex_stisr.c

I assume your PIC is the master on the SPI bus? Then reading the SPI data is easy and can be implemented without interrupts. Again, examples can be found in the CCS example directory and on this forum.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 30, 2013 11:38 am     Reply with quote

This thread has a sample program which puts incoming SPI data in a
ring buffer:
http://www.ccsinfo.com/forum/viewtopic.php?t=26888
spi_kbhit - Tells if data is available in the ring buffer.
spi_bgetc - Is used to get a byte of data from the ring buffer.
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