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

PIC16F877A RS232 hardware configure.

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








PIC16F877A RS232 hardware configure.
PostPosted: Sun Nov 15, 2009 5:28 am     Reply with quote

Hi,
I need to configura MAX232 and PIC16F877A with with RS232 of my radio tranceiver
The radio manual say
-----------------------------------------
This transceiver uses a full-duplex, asynchronous,
serial interface for communicating through the male
9-PIN RS-232C COM connector. Each data is
constructed with 1 start bit, 8 data bits, and 1 stop bit
No parity is used.
-----------------------------------------
I have
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
but this config not work.
missing 1 stop bit ?.
any suggestion is appreciated
Thanks
Jo
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 15, 2009 6:29 am     Reply with quote

1 stop bit is the default configuration. Your #rs232 line looks correct.

Without more information it is impossible to say where your problem is. It could be both the hardware or software.

Check your hardware by connecting the PIC to your PC. Use the program below for testing, it will echo the data you enter at the PC back to the PC.
Code:
#include <16F877A.h>
#fuses HS, NOWDT NOLVP, NOPROTECT
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, ERRORS)


void main()
{
  int8 data;
 
  while(TRUE)
  {
    data = getc();
    putc(data);
  }
}

Note the ERRORS keyword I added, this causes the compiler to add extra code for clearing the UART receive buffer overflow status at every call to getc(). Without this the UART stops receiving data in situations where you have received more than 3 characters without reading.

If this works another thing to check is the connection to your radio. Does this require a straight or cross connection?
Guest








PIC16F877A RS232 hardware configure.
PostPosted: Sun Nov 15, 2009 7:04 am     Reply with quote

Thanks,
Pic work well with PC. The PC work well with CAT RS232 of the tranceiver, but the PIC not work with CAT RS232 of the tranceiver.
Perhaps we should revise the cable between the PIC and the transceiver ?
From manual :
"Only 3 lines are required theoretically for control of
the transceiver via the computer:
• Transmit data
• Receive data
• Ground
From a practical standpoint, it is also necessary to
incorporate some means of controlling when this data
transfer will occur. The computer and transceiver
cannot be allowed to send data at the same time!
The required control is achieved by using the RTS
and CTS lines"
Could be connected with RTS and CTS ?
Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Nov 15, 2009 7:30 am     Reply with quote

The quoted manual statement regarding RTS/CTS usage sounds confused. Either the transceiver requires the
peer to pay attention to the CTS line in some situations (e.g.insufficient buffer space) or it doesn't. A problem of
simultaneous sending of both peers is a different matter. It's not possible, because the RF link is usually simplex only.
But the problem has to be handled on a protocol layer, a transceivers CTS signal can't reflect the fact, that the
other side intends to send next.

Small radio devices are usually transmitting in packets and don't need hardware flow control. Of course the
PIC firmware must be able to buffer an incoming packet, otherwise it has to use RTS.
Ttelmah
Guest







PostPosted: Mon Nov 16, 2009 3:35 am     Reply with quote

And, yes on the cable.

You need to reverse pin 2, and pin 3 of the cable used to connect to the PC, to talk to the transceiver.
Basically, RS232 equipment, can be 'DTE' (data terminal equipment), or 'DCE' (data communications equipment - things like modems). The PC, is wired as 'DTE', so can talk to either the PIC (wired as DCE), or the radio modem (also DCE). For your PIC to talk to the modem, you have to swap the PIC wiring so it acts as a DTE. Fortunately for simple serial, using only three wires, all that needs to happen is that the transmit and receive wires (pins 2 a 3), have to be swapped.

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