Question : Problem: 8051 serial comms with rts & cts

I am currently using an 8051 variant (P89C664) and a MAX202 to use serial comms and ISP. I do all my programming in C in Keil uVision. The current code I have is:

void InitSerial()
{
    // Initialize the serial port (9600, 8, N, 1)
    PCON &= 0x7F;
    TCON_5 = 0;
    TCON_4 = 0;
    S0CON = 0x50;
    TMOD |= 0x20;
    TH1 = 0xF5;    // Timer #1 overflow rate (T1H = 256 - (Fosc / (192 * BR)))
    TR1 = 1;
    TI = 1;
}

This works fine using printf() and getchar(), but now I need to have RTS and CTS lines as well as RxD, TxD and GND. I figure this will involve using a couple of ordinary pins or the external interrupt, but I'm not too sure.

The prupose of this is to communicate with a PC over 2 BRM01 Bluetooth modems from www.rfsolutions.co.uk The data being sent & recieved will most likely be in the form of an ID tag and a value (ie M-895).

I really need the code for the serial comms, but any extra advice about passing data to and from the PC would be welcome. Thanks.

Answer : Problem: 8051 serial comms with rts & cts

When I have done this I use normal port pins and polling. When you are ready to transmit data check the status of the pin to determine you can start sending. When you are busy processing data you can set the port pin to halt the remote from sending you data. It is all just handshaking. Jan Axelrod has a book on serial ports that should be very helpful for implementing handshaking protocols.
Random Solutions  
 
programming4us programming4us