View previous topic :: View next topic |
Author |
Message |
simat
Joined: 05 Feb 2008 Posts: 7
|
Inverted RS232 |
Posted: Mon Feb 11, 2008 11:54 am |
|
|
Hi,
Does anybody know if #use RS232 will support the INVERT function for receiving data ? , I know it works for transmission.. The data is going over a radio so I'm hoping not to have to use a H/W inverter for input.
Code: |
#use rs232(baud=1200, INVERT, rcv=PIN_B1, stream=radioRX)
|
Thanks
Simon.
http://www.simat.org.uk |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 11, 2008 2:33 pm |
|
|
Yes, the INVERT parameter applies to both Rx and Tx for a software UART. |
|
|
simat
Joined: 05 Feb 2008 Posts: 7
|
|
Posted: Tue Feb 12, 2008 6:59 am |
|
|
If I use the 'INVERT' function should the ISR still fire ?
I'm receiving inverted data on B0 of a 16F628A (s/w USART), I need this to fire an interupt - read the data is, parse it and then send it out non-inverted on B2 which I think is the H/W USART TX pin
Code: |
#use rs232(baud=1200, invert , rcv=PIN_B0, stream=radioRX)
#use rs232(baud=1200, xmit=PIN_B2, stream=emsTX)
..
#int_RDA
void RDA_isr(void)
{
int t;
disable_interrupts(INT_RDA);
disable_interrupts(GLOBAL);
buffer[next_in]=fgetc(radioRX);
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
cycles++;
enable_interrupts(GLOBAL);
enable_interrupts(INT_RDA);
}
|
I guess the interupt is looking at the H/W USART on B2, may be it's expecting an input change on B1 (RX) .. does anybody have any clues as to why the ISR doesn't fire when the input on B0 goes high ?
Thanks
Simon.
http://www.simat.org.uk |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Feb 12, 2008 8:11 am |
|
|
Interrupts can only be generated by a hardware unit. The CCS soft UART does not generate interrupts.
There do exist (commercial) software UART implementations that use the external interrupt pin for generating an interrupt.
Life is much easier when you can use the hardware UART, especially on receiving. What is against the addition of an external hardware inverter? A simple TTL chip or FET/resistor combination would do the trick. Even better, you are sending and receiving at the same speed so you can use the same hardware UART for Rx and Tx. |
|
|
simat
Joined: 05 Feb 2008 Posts: 7
|
|
Posted: Tue Feb 12, 2008 8:18 am |
|
|
thanks for the replies, we'll use the H/W USART and invert the input as low power operation at the receiver isn't too critical.
Simon
http://www.simat.org.uk |
|
|
|