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 CCS Technical Support

Using SPI and Asynchronous UART simultaneously

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



Joined: 05 Sep 2014
Posts: 13

View user's profile Send private message

Using SPI and Asynchronous UART simultaneously
PostPosted: Tue Oct 07, 2014 9:06 am     Reply with quote

Good afternoon. Quick question....

On a PIC such as the PIC16F690 which contains only the 1 EUSART, is it possible to write code using CCS to operate the uC both as an interrupt driven SPI Slave and interrupt driven RS232 simultaneously?

We are currently using compiler v4.121.

All the best,
Colin
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 9:22 am     Reply with quote

quick answer

no

reason, PIC like 99.999% of all computers only has 1 ALU hence it is impossible to simultaneously do 2 things at once.


jay
MrColin



Joined: 05 Sep 2014
Posts: 13

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 9:29 am     Reply with quote

Perhaps simultaneously gave the wrong impression. The device I'm working on is a serial buffer which is communicated via SPI. The hope is RS232 data is buffered coming in, and sent back over SPI; and SPI data coming in is buffered and transmitted via RS232.

So, say data is coming in on the SPI line and this device is operating as a slave. The interrupt #int_SSP will be picking up data being clocked in. Is it possible for #int_RDA to also be active?

Would a valid approach be to disable RS232 during data transfer over the SPI network? There is the opportunity for data loss, but SPI is significantly faster than the UART so it may be possible to squeeze a good amount of data in the available window.

My apologies if this was covered in your quick answer from before.
SuperDave



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 07, 2014 9:42 am     Reply with quote

Assuming you are not limited to the 16F690, go here
http://www.microchip.com/ParamChartSearch/Chart.aspx?branchID=1012
and select 2 SPI interfaces and 2 UART interfaces. Lots of inexpensive choices that should do what you want easily.
MrColin



Joined: 05 Sep 2014
Posts: 13

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 9:57 am     Reply with quote

Sadly I've been asked to write code for an existing product. The old version of this product used i2c and rs232 to do the same job. This has been written in assembler and works fine, however I've been asked to reimplement it in C using the SPI interface, hence asking in the compiler forum.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 10:11 am     Reply with quote

Ok...I looked at the datasheet and the 690 uses separate pins for UART vs SPI so depending on the UART speed...it should be possible, providing you use buffers for everything. CCS does give you examples of UART ISR with buffering( ex_sisr.c) as well as one for a transmit buffer using an ISR.
Providing there's not much else going on(no FP math etc.) ,just data in----data out, it should work fine.
I've used the 18F46K22 with 2 hardware UARTs at 115k200 in a silly in1-out 2,in2-out 1 test and never lost a byte using the ISr/buffers approach.

hth
jay
MrColin



Joined: 05 Sep 2014
Posts: 13

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 10:21 am     Reply with quote

Amazing. Thanks for checking that out temtronic (jay). It's really appreciated!
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