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

#use rs232 doesn’t make the RX pin an input

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

#use rs232 doesn’t make the RX pin an input
PostPosted: Sat Jun 23, 2007 9:20 pm     Reply with quote

Colleagues,

For some reason #use rs232 directive didn’t set the RX pin as input (RB2 in my case). I had to call input(PIN_B2) Is it a good workaround? Could there be a problem elsewhere?

Cheers,
Nick

Code:

#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8,stream=rs232)

void main()
{
   // ...
   input(PIN_B2);    // this line ended up being necessary to make the RX pin an input.  #use rs232(...) doesn't do it alone
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   while (1)
   {
      // ...
   }
}


Hardware: 18F88 in 28-pin QFN, Vcc = +5V, internal RC 8MHz
CCS: 3.240
_________________
Read the label, before opening a can of worms.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Jun 23, 2007 9:40 pm     Reply with quote

Quote:

#use rs232(...) doesn't do it alone

It never do it alone unless you invoke getc() or fgetc(rs232) in your code (or any other STDIN).


Humberto
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sat Jun 23, 2007 9:46 pm     Reply with quote

Humberto wrote:
It never do it alone unless you invoke getc() or fgetc(rs232) in your code (or any other STDIN).

Are you joking?
If you're not, I meant that #use rs232(...,rcv=PIN_B2,...) alone doesn't make PIN_B2 an input, although it probably should. I have fgetc(rs232) in the serial ISR code (which I didn't post).
_________________
Read the label, before opening a can of worms.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Jun 23, 2007 10:56 pm     Reply with quote

I´m not joking.
#use rs232(...) is a preprocessor directive only, and takes effect until another
directive is encountered that will disabled it.
You didn´t show us your header nor your code, and I guess this will be the case.
Anyway, #use rs232(...) tells the compiler the pins used for serial Input/Output,
that it is not just like a supposition that rcv pin is an input only, this temporary pin
status will be changed with another directive if used.


Humberto
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