View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
#use rs232 doesn’t make the RX pin an input |
Posted: Sat Jun 23, 2007 9:20 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Jun 23, 2007 9:40 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sat Jun 23, 2007 9:46 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Jun 23, 2007 10:56 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|