Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Mon Feb 04, 2019 9:19 am |
|
|
It's 'sort of possible'.
Basically all you do, is setup a software UART which received on a pin
that supports a 'level' interrupt.
Then set this to interrupt on a falling edge.
In the interrupt routine, call the software UART getc.
Then what happens is on the falling edge on the input pin, the handler
gets called, and the getc is then called.
If using a faster baud rate, you may have to set the software UART to
use the option 'SAMPLE_EARLY'. This means it starts reading data as soon
as it is called, rather than waiting for half a bit time after this. Reason is
that it will typically take perhaps 30 instruction times to actually get into
the interrupt handler, and if this was (perhaps) nearly half a bit time,
the software UART would be reading too late in the bit. However unless
your clock rate is very slow, this is not likely to be an issue at 4800bps.
However big caveat is that the code will remain in this handler for 1/480th
second (10 bits at 4800bps), which may cause issues with other interrupts.
Also separately on transmit, other interrupts can/will cause timing errors
with this, and (worse), if you get a receive interrupt while transmitting,
you will have problems....
I did publish in a thread a while ago, a 'timer' based software UART to
give more 'friendly' behaviour. A search should find this.
Update: The timer based software UART is here:
<http://www.ccsinfo.com/forum/viewtopic.php?t=39958&highlight=software+rs232+disturbed+interrupts> |
|