|
|
View previous topic :: View next topic |
Author |
Message |
troky
Joined: 14 Dec 2003 Posts: 6
|
Problems with re-enabling RS232 transmitter |
Posted: Sun Feb 15, 2004 7:23 am |
|
|
Hi all,
I am having problem with disabling TX line in PIC16f628. In my application I TX line is needed to be in high-Z state except some transmission is done. Here is what I tried and doesn't work good:
1. using HARDWARE UART: on setup tx is disabled by clearing TXEN bit. When I need to do some transmission TXEN bit is set (and TRISB.B2 is cleared), and after transmission is done (checking TRMT and TXIF bits), TXEN is cleared again and TRISB.B2 is set. This doesn't work. If I remove setting TRISB.2 tx is done but pin_B2 is not in high-Z state.
2. using HW UART for RX and SOFTWARE UART (on pin_B6) for TX: I thought FLOAT_HIGH command for sw uart will help me... but it didn't. Without FLOAT_HIGH, everything works good but pin_B6 is not in high-Z state, and with FLOAT_HIGH there is no transmission at all!
What to do?? Thing is that I NEED TX pin to be in high-Z state all the time except for transmission.
Any solution, software or hardware, will be much appreciated.
Thanks,
Troky |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 15, 2004 12:56 pm |
|
|
Post two short programs -- one for the hardware USART, and one
for the software USART. In each one, show how you attempt to
turn the USART off, and then on again.
Tell us how you test it, to show that it's working, or that it failed.
The programs should be complete, compilable code, including all
#fuse statements, #use statements, #include files, etc.
Also post the version of your compiler.
Once you've done that, we'll analyze the problem and find an answer. |
|
|
troky
Joined: 14 Dec 2003 Posts: 6
|
|
Posted: Sun Feb 15, 2004 5:09 pm |
|
|
Here is partial code:
#include <16F628.h>
#fuses NOWDT,HS, PUT, PROTECT, NOBROWNOUT, NOMCLR, NOLVP, NOCPD
#use delay(clock=9830400)
#use rs232(baud=19200,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8)
#bit txen = 0x98.5
#bit trmt = 0x98.1
#bit TRISB2 = 0x86.2
//------
void TxEnable()
{
output_high(pin_B2);
TRISB2=0; //output
txen=1;
}
void TxDisable()
{
while(!trmt) delay_us(10);
txen=0;
TRISB2=1; //input - HIGH-Z
}
//... somewhere in main loop
TxEnable();
printf("CMD GET\r");
TxDisable();
//...
Problematic line is "TRISB2=1". If I remove it everything works fine. If I leave it INT_RDA never gets triggered on incoming data.
Transmission works fine always.
Troky |
|
|
|
|
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
|