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

How To Pull UART high?

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



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

How To Pull UART high?
PostPosted: Mon Jun 05, 2006 7:34 am     Reply with quote

Hi

I am seeing "dummy" characters on my receive pin of the PIC16F873
i.e. pin_C7.

The poster Ttelmah warned me:
Quote:

However remember that unless the receive input of the UART is pulled high, 'dummy' characters may be seen, and a receive interupt occur.

Can someone please tell me how I can "pull the UART high"?

Thank you.
a.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 7:42 am     Reply with quote

Connect RX and TX to Vdd through a 4.7K to 10K resistor.

Good luck,

John
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 7:45 am     Reply with quote

It depends totally on how you have your circuit connected. Normally, provided you have the RX pin of the chip, connected via a MAX232 or similar transciever, and wired to a transmit pin on another serial port, the pin will always be 'pulled high', when no data is being received. However there can be problems. For instance, Dell laptops, in order to save power, stop driving the serial line when data is not beng sent for a while. Similarly, if you are connecting to another device that does not guarantee to drive the pin high when idle (some serial radio receiver modules in particular), then you either have to write your code to deal with the 'break' condition that this corresponds to, or arrange the hardware to pull the pin high. Solutions will depend totally on what _you_ are connecting. For instance, some of the radio modules have a 'carrier detect' output, and this can be connected with simple logic, to pull the signal high, when no carrier is seen.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 7:51 am     Reply with quote

Hi Ttelmah and Jecottrell

I am connecting my PIC to a SMiRF from Sparkfun- this is a BlueTooth transceiver.

So do you agree with Jecottrell- can I connect Pin C6 and C7 to Vdd via a 5k resistor and still transmit and receive data?

Thank you
a.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 8:04 am     Reply with quote

Hi

I have just put the Tx from the SMiRF onto an Oscope.

When its not connected to the PIC16F873 I see 5V.
When its connected to the PIC16F873 Pin_C6 I see 1V.

Does this sound right to you?

All the best
a.
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 8:19 am     Reply with quote

Hint.
The TX pin on the SMiRF, goes to the RX pin on the PIC, and vice verse...

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 8:43 am     Reply with quote

Hi

Yes I did do that Tx on the SMiRF to Rx on the PIC
and the Rx on the SMiRF to the Tx on the PIC.

I have put a 7.2k resistor from PIN_C7 to Vdd.

Also, will a printf command be interrupted by an
int_rda?

Thank you
a.
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 9:09 am     Reply with quote

On your earlier post, you talk about connecting TX on the module to C6 (which is TX on the PIC..).
Yes, a printf, will be interupted, _provided_ you are not using a printf inside the interrupt.
It is probable, that you may have to write the code to be 'break tolerant' on a radio like this. It'd be perfectly normal for the unit to drop the RX line, when the bluetooth connection is lost. You need to find out from the manufacturer, what the unit does in this case. If it does issue a 'break' (pulling the receive line permanently low), then you may have to consider running the line into another pin like the B0 interrupt as well, and disabling the receive routine, if a break character is received, and only re-enabling it if the line rises.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 9:22 am     Reply with quote

Hi Ttelmah

Sorry I made a typo- I am running the Tx and Rx lines correctly (as far as I can tell). I do receive the data by having a printf in the main program.

However, I cannot get the data to stop being sent- using the int_rda. It seems that the int_rda is being ignored during the printf.

When the printf is not operating I do get an interrupt in the int_rda routine (this is what starts the whole data transmission).

I am just wondering if I should use something other than int_rda.
kbhit()?

I would appreciate any suggestions that you might have
a.
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 9:40 am     Reply with quote

There seems to be a crossover in what you are saying. INT_RDA, has nothing to do with _sending_ data, yet you say:
" I cannot get the data to stop being sent- using the int_rda".
INT_RDA, reflects data _arriving_ at the PIC only.
Now it is possible that int_rda, is being disabled in the printf, but if so, this is because of something being used in both locations. What does your RDA interrupt do?. Look at the EX_SISR.c, for an example of how to use the receive interrupt to handle incoming communications. I suspect you are sending data from the RDA interrupt (your comment about using this to start a transmission suggests this), and if so, then this is why the interrupt is disabled in the printf.
If the code is inside a printf, you won't be able to get to a kbhit routine. Kbhit, only software 'polls' the same flag that triggers the interrupt.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 9:48 am     Reply with quote

Hi Ttelmah

If I may explain my problem:

I have the following code:

Code:

#int_rda
void interuptIn(){
   ch = getc();
   if(ch==36)
      setFlag = true;
   if(ch==42)
      setFlag = false;
}

main(){
   setFlag = false;
   while(true){
      if(setFlag)
          printf("ok here we are");
   }
     


I would like to send a character "36" and for it to start printing "ok here we are" to the hyperterminal repeatedly.
While this is happening- I would like to hit the keyboard with character "42" and for the transmission (printf) to stop.

Can you see anything wrong with the code?
Thank you
a.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 11:04 am     Reply with quote

Here is a tip that will go a long way when starting any project:

Build up hardware and software one piece at a time. That way you'll never have to decide what is causing 'the' problem.

So, start with a simple routine such as this to see if your PIC is transmitting as expected:

Code:

main() {

   delay_ms(1000);   //delay 1 second between transmits

   printf("ok here we are\n\r");   //test print and CRLF

}




Once you decide that is working as expected we'll try to help you with the receive interrupt. But only one piece at a time.....

John
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 05, 2006 11:49 am     Reply with quote

Here is another hint. STAY WITH YOUR SAME POST!

http://www.ccsinfo.com/forum/viewtopic.php?t=27206
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