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 support@ccsinfo.com

Unable to interface TXN & RCV output

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



Joined: 19 Jul 2006
Posts: 8

View user's profile Send private message

Unable to interface TXN & RCV output
PostPosted: Wed Jul 19, 2006 2:57 pm     Reply with quote

I'm trying to interface a TXN and RCV output from an outside device into the software prototyping board and use the microchip to input certain characters back to the device and output the results of the typed characters. I've been trying two seperate streams for the rs232 but I have been unable to succeed. When I connect the outputs from the other device directly to the rs232 TXN and RCV, I get the output in the serial input/output. All I want to do is have the microchip serve as the 'typer', and 'type' in a certain character (in an infinite while loop with a delay of course) and output the resulting output without me having to continually press the letters. I hope that wasn't too confusing. It sounds so simple, but I just can't do it!

V.S.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 19, 2006 4:26 pm     Reply with quote

It sound like you have a mystery device and if you connect it to your PC,
you can type in characters in a terminal window and send them to the
device. It then sends back some characters which are displayed in
your PC's terminal window.

You want to have a PIC (which you strangely call a "microchip") send
the characters to the mystery device instead of you typing them in.

So, just disconnect the wire between the Tx pin on your PC and the
Rcv pin on your device. (You will still have the connection between
the Rx pin on the PC and the Tx pin on the device, as well as a ground
connection.

Then connect the Tx pin on the PIC (pin C6 on a 16F877) to a MAX232-
type chip, and take the output to the Rcv pin on your device. Also make
sure there is a ground connection between the PIC and your device.

You don't need two streams for this, as you only need the Tx output
from the PIC. You don't even need to specify a stream. Just use
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
to tell the compiler to use the hardware UART. (Assuming your PIC
has one -- you didn't tell us what PIC you're using).
Guest








PostPosted: Thu Jul 20, 2006 3:50 pm     Reply with quote

Hey PCM Programmer,
Thanks for the incite. But unfortunately, I still cannot get the program to successfully output what I need. The PIC I'm using is the 16F877A, along with the ACE Kit. I'm very new to all this programming, so I'm having a hardtime understanding the TXN and RCV connections. It's likely I just misunderstood your instructions. When the program interacted with the keyboard input, I connected the "txn" to C6 and the "rcv" to C7 (as labelled on the 'mystery device') and it worked correctly. I'm not sure how you mean for me to disconnect the wire and run it through the MS232-type chip as my software prototyping board has already wired the serial port into the ms232-type chip and straight to the C6 & C7 pins. Perhaps, more mechanical instructions would help. I Appreciate the help.


V.S.

P.S. When trying to follow your instructions, I ended up with both the 'rcv' and 'txn' from the device going into C6 (C6 and C7 went to port 12 and 11, respectively on the software prototyping board).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 4:00 pm     Reply with quote

I assumed that your original working mode, was with the "device"
connected to your PC (with no PIC involved at this point).

Apparently that's not the case ?

Also, your terminology is confusing. You keep referring to "TXN",
but in the PIC data sheet, the hardware UART pins are referred to
as "TX" and "RX". So I'm not sure what you're really connected to.
Is "TXN" a PIC pin, or is it on the PC, or is it on the "device" ?
masssystems



Joined: 19 Jul 2006
Posts: 8

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 4:18 pm     Reply with quote

Well, from my device I have two connections, one reading 'T' and the other 'R'. I don't know if you're familiar with the software prototyping board of the ACE kit, but I used the wiring connecting C6 to <rs232>rs232-A (which is recieve) and my 'T' was connected to C6 and 'R' to C7. That setup worked, with input coming through my keyboard. My serial port is connected to a "MAX232D" chip with connections to 'T2OUT' and 'R2IN' and the connections 'R2OUT' and 'T2IN' from the MAX232D chip go to >RS232-A & <RS232-A, respectively. Sorry about the confusion earlier, I mistakenly used TXN when I meant to use xmit. I still don't fully understand how I can do this with one stream. Thanks.


V.S.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 4:43 pm     Reply with quote

So there is no PC involved at all.
When you referred to "keyboard" (which implies a PC), you really
meant the keypad, which comes with the ACE kit. Link to keypad:
http://www.ccsinfo.com/product_info.php?products_id=lcdkeypad

You didn't post any code, but I assume that currently you're
getting keypad input by a method similar to that shown in the
CCS example file, EX_LCDKB.C, and sending to the device.
Something like this:

Code:
while (TRUE) {
      k=kbd_getc();
      if(k!=0)
          putc(k);  // Send keypad char to the device
   }



To replace the keypad with an automatic loop that will send a character
to your device periodically, then do something like this:

Code:
while(1)
  {
   putc('A');   // Send an 'A' character
   delay_ms(1000);   // Wait 1 second
  }

This will send 'A' to your device once per second.
masssystems



Joined: 19 Jul 2006
Posts: 8

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 4:54 pm     Reply with quote

I'm actually using a serial port connection to my PC which transfers two signals to the 'T2OUT' and 'R2IN' pins on the MAX232D. The connection from my rs232 port (on my PC) goes through the MAX232D and the 'R2OUT' and 'T2IN' pins from the MAX232D go to the '>RS232-A' and '<RS232-A', respectively (which I can plug into via a breadboard). My code is very simple, and listed below:
Code:
#include<16F877A>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)


void main()
{

   while (TRUE)
   {
      putc('T');
      delay_ms(1000);
      putc('P');
      delay_ms(1000);

   }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 5:02 pm     Reply with quote

I'm going to give up. I am mis-interpreting your posts too much of
the time to be able to give any help.
masssystems



Joined: 19 Jul 2006
Posts: 8

View user's profile Send private message

PostPosted: Thu Jul 20, 2006 5:19 pm     Reply with quote

Ok, I appreciate the help anyway.
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