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

Problems with re-enabling RS232 transmitter

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



Joined: 14 Dec 2003
Posts: 6

View user's profile Send private message

Problems with re-enabling RS232 transmitter
PostPosted: Sun Feb 15, 2004 7:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Feb 15, 2004 12:56 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Feb 15, 2004 5:09 pm     Reply with quote

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