|
|
View previous topic :: View next topic |
Author |
Message |
dex2k
Joined: 26 May 2006 Posts: 6
|
Interrupt driven rs232 port on different pins |
Posted: Sun May 28, 2006 3:02 pm |
|
|
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
|
|
Posted: Sun May 28, 2006 4:57 pm |
|
|
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
|
|
Posted: Sun May 28, 2006 7:53 pm |
|
|
its about 03:00 at night here, just woke up with the same idea as yours, what an odd world we live in
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
thanks for your quick help |
|
|
Ttelmah Guest
|
|
Posted: Mon May 29, 2006 4:04 am |
|
|
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 |
|
|
|
|
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
|