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 CCS Technical Support

Inverted RS232

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



Joined: 05 Feb 2008
Posts: 7

View user's profile Send private message Visit poster's website

Inverted RS232
PostPosted: Mon Feb 11, 2008 11:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 2:33 pm     Reply with quote

Yes, the INVERT parameter applies to both Rx and Tx for a software UART.
simat



Joined: 05 Feb 2008
Posts: 7

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 12, 2008 6:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 12, 2008 8:11 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 12, 2008 8:18 am     Reply with quote

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