|
|
View previous topic :: View next topic |
Author |
Message |
Kasper Buhl Guest
|
Port Conflict ??? |
Posted: Thu May 29, 2003 2:21 pm |
|
|
Is it possible to have the use RS232 directory remain in effect for just one pin: RB0 and still use the other pins on port B for input/output without annoying the RS232 communication at all ???
I am fresh running out of ports if this cannot be done :-/
Pic: 16F872
In specific:
How can I set RB1-RB7 to input/output, be able to put/recieve data on them and still have the RS232 function normally (as before manipulating the spare pins on the port) ?
Thanks in advance
Regards
Kasper Buhl
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514863 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Port Conflict ??? |
Posted: Thu May 29, 2003 2:48 pm |
|
|
:=
:=Is it possible to have the use RS232 directory remain in effect for just one pin: RB0 and still use the other pins on port B for input/output without annoying the RS232 communication at all ???
----------------------------------------------------------
You can create a "#use rs232" statement that only defines
one pin on Port B. See the example below. It has the
hardware RS232 on Pins C6 and C7, and it also has software
RS232 on Pin B0 (receive only). You could change pin B0 to
be a transmit pin instead, if that's what you want.
<PRE>
#include "c:\Program Files\Picc\Devices\16F877.H"
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, ERRORS, stream=HW_UART)
<BR>
#use rs232(baud = 9600, rcv = PIN_B0, stream=SOFT_UART)
<BR>
<BR>
void main(void)
{
char c;
<BR>
c = fgetc(SOFT_UART);
<BR>
while(1);
}
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514864 |
|
|
Kasper Buhl Guest
|
Re: Port Conflict ??? |
Posted: Thu May 29, 2003 3:21 pm |
|
|
<font face="Courier New" size=-1>Thankyou for the speedy answer. It answered another problem I had been puzzling with: how to use 2 RS232 on on pic => simply use stream !
Im not sure I expressed myself correctly, however:
What I meant was:
Can I use the pins on port B that I do NOT use for RS232 as a means of lighting diodes, turning on spindles motors etc. without annoying the RS232 on pin RB0.
Will a set_tris_B(0x00) annoy/disable the RS232 on RB0 ?
What do I have to do to set f.inst. RB2,3,4 and 5 to Output pins, be able to put them high/low for the above mentioned purpose and NOT annoy the RS232 at all ?
Would it help to OR/AND/XOR the tris statement somehow or can I simply "TRIS" a single pin without messing the RS232 up on RB0 ?
So you see what I am asking is whether or not the Use RS232 directive really "occupies" the entire port, eventhough it is only using the RB0 for xmit and rcv and thus preventing other functions to use the beforementioned "idle" pins on port B.
It would be easier to use another port, I know, but I do not have that luxury :-/
Please excuse my lack of English linguistic knowledge/spelling/whatever, no harm/offense intended :-)
Regards
Kasper Buhl</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514866 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Port Conflict ??? |
Posted: Thu May 29, 2003 3:34 pm |
|
|
<font face="Courier New" size=-1>:=Thankyou for the speedy answer. It answered another problem I had been puzzling with: how to use 2 RS232 on on pic => simply use stream !
:=
:=Im not sure I expressed myself correctly, however:
:=What I meant was:
:=Can I use the pins on port B that I do NOT use for RS232 as a means of lighting diodes, turning on spindles motors etc. without annoying the RS232 on pin RB0.
:=Will a set_tris_B(0x00) annoy/disable the RS232 on RB0 ?
It sure will. It will change pin B0 to an output.
So if you want to use pin B0 as an RS232 input, then change
your tris statement to set_tris_B(0x01)
:=
:=What do I have to do to set f.inst. RB2,3,4 and 5 to Output pins, be able to put them high/low for the above mentioned purpose and NOT annoy the RS232 at all ?
Use the tris statement I gave above, or, use standard i/o
(the default for CCS) and use these functions to toggle pins:
output_low(PIN_B2);
output_high(PIN_B2);
output_low(PIN_B3);
output_high(PIN_B3);
output_low(PIN_B4);
output_high(PIN_B4);
output_low(PIN_B5);
output_high(PIN_B5);
:=Would it help to OR/AND/XOR the tris statement somehow or can I simply "TRIS" a single pin without messing the RS232 up on RB0 ?
You don't really even need to use the Tris statement at all.
Just use standard i/o and use the output_low() and output_high()
functions as I've shown above. You don't even need to specify
standard i/o mode to the compiler, since it's the default mode.
Just use those functions above.
:=
:=So you see what I am asking is whether or not the Use RS232 directive really "occupies" the entire port, eventhough it is only using the RB0 for xmit and rcv and thus preventing other functions to use the beforementioned "idle" pins on port B.
It only uses the specified pin. (ie., B0).
:=
:=It would be easier to use another port, I know, but I do not have that luxury :-/
:=
:=Please excuse my lack of English linguistic knowledge/spelling/whatever, no harm/offense intended :-)
:=
:=Regards
:=
:=Kasper Buhl</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514869 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: Port Conflict ??? |
Posted: Thu May 29, 2003 4:42 pm |
|
|
:=
:=Is it possible to have the use RS232 directory remain in effect for just one pin: RB0 and still use the other pins on port B for input/output without annoying the RS232 communication at all ???
:=I am fresh running out of ports if this cannot be done :-/
:=
:=Pic: 16F872
:=
:=In specific:
:=How can I set RB1-RB7 to input/output, be able to put/recieve data on them and still have the RS232 function normally (as before manipulating the spare pins on the port) ?
:=
:=Thanks in advance
:=
:=Regards
:=
:=Kasper Buhl
Using Fast I/O will require setting the Tris bits manualy but also will reduce code size and increase speed of operation. Standard I/O requires less effort and is more forgiving.
Setting the Tris byte for the port will set the direction for each pin as input or output. This is only required when changing I/O direction for a pin. Keep in mind that a software serial port uses all of the processing time during transmition and reception of bytes. Don't expect to toggle those pins while sending or recieving a byte on your software port.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514871 |
|
|
Kasper Buhl Guest
|
Re: Port Conflict ??? |
Posted: Fri May 30, 2003 4:33 am |
|
|
Thankyou, sir :-)
I will do as you suggest.
Regards
Kasper Buhl
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514882 |
|
|
|
|
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
|