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

Interrupt driven rs232 port on different pins

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



Joined: 26 May 2006
Posts: 6

View user's profile Send private message

Interrupt driven rs232 port on different pins
PostPosted: Sun May 28, 2006 3:02 pm     Reply with quote

Is it possible to get interrupt capabilities on other pins than the hardware pins rx/tx on a pic18f4550 or pic18f452?

I need to do some SPI operations and have an interrupt enabled for a serial port at the same time.
Is this possible, or how do you people cope with sharing the dataout pin?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 28, 2006 4:57 pm     Reply with quote

The INT0, INT1, or INT2 pins can be used as the Rx pin for a soft UART.
You can then use the corresponding external interrupt (INT_EXT,
INT_EXT1, or INT_EXT2) to detect the leading edge of the start bit.
(This is the falling edge). The incoming byte is then read with a getc()
or fgetc() statement, inside the INT_EXTx interrupt service routine.

However, there are many PICs to choose from. The best way is to
use a PIC that has the SPI and UART modules on separate pins.
dex2k



Joined: 26 May 2006
Posts: 6

View user's profile Send private message

PostPosted: Sun May 28, 2006 7:53 pm     Reply with quote

its about 03:00 at night here, just woke up with the same idea as yours, what an odd world we live in Smile

i have seen that some of the "great" pic series has separate uart and spi pins, but i dont have that option, so the external interrupt idea must be my road to victory Smile

thanks for your quick help
Ttelmah
Guest







PostPosted: Mon May 29, 2006 4:04 am     Reply with quote

This however is very dependant on using a relatively slow serial rate. Look at the RS485.c driver/example, which (depending on configuration), uses an interrupt triggered 'soft' serial stream for the RS485 comms, and hardware serial for it's general I/O. The problem with the 'soft' approach, is that if the interrupt occurs on the edge of the incoming character, there is a significant time interval, before the code gets into the handler. If this is too long (relative to the 'bit' width of the incoming stream), data may get lost/corrupted. For a chip at 40MHz, this delay, is perhaps 4uSec, and reasonable serial rates can be handled, but if you are running at a much lower clock rate, this needs to be considered...
You could also consider a separate SPI UART module.
On chips like the 18F2550, it is possible to have the UART in use, and also the SPI, in receive mode only.
Remember also that bit-banging SPI, is fairly easy, and fast.

Best Wishes
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