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
Posted: Tue Apr 30, 2013 6:40 am
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
Posted: Tue Apr 30, 2013 7:44 am
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
Posted: Tue Apr 30, 2013 11:38 am
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.
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