View previous topic :: View next topic |
Author |
Message |
MrColin
Joined: 05 Sep 2014 Posts: 13
|
Using SPI and Asynchronous UART simultaneously |
Posted: Tue Oct 07, 2014 9:06 am |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Tue Oct 07, 2014 9:22 am |
|
|
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
|
|
Posted: Tue Oct 07, 2014 9:29 am |
|
|
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
|
|
|
MrColin
Joined: 05 Sep 2014 Posts: 13
|
|
Posted: Tue Oct 07, 2014 9:57 am |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Tue Oct 07, 2014 10:11 am |
|
|
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
|
|
Posted: Tue Oct 07, 2014 10:21 am |
|
|
Amazing. Thanks for checking that out temtronic (jay). It's really appreciated! |
|
|
|