The purpose of this project is to demonstrate the use of a MAX232 with an AVR, specifically an ATtiny4313, but the concept applies to all AVR's that have UARTS or USARTS. The MAX232 provides two RS232 transmitters and two RS232 receivers.
This circuit is in response to a specific question about AVR devices implementing RTS/CTS handshake. This is the hardware - I'll leave it to the reader to decide what to do with the software. It would be hard to provide code, since the implementation is fairly specific to the task at hand. This answer is specifically about RTS/CTS protocol, which governs master to slave communication. It does not have anything to do with slave to master communications, which is not really addressed properly, since at the time RS232 was being defined, the master was a mainframe, and the slave was a seriously dumb terminal or some other 75 Baud peripheral. A friend of mine has a Univac RS-232 port. It is the size of a two drawer file cabinet and takes two people to tip over.
RS232 defines logic states, just like anyone else in the digital world, except for the fact that all signals in RS232 land are inverted, and are +/- 3 to 30 VDC. A logic "0" from the AVR point of view is 0 VDC, where the RS232 signal would be inverted and would be (typically) +12 VDC. When the AVR outputs a logic "1", it is at Vcc, which may be around +5 VDC. The RS232 driver will output -12 VDC.
RTS/CTS handshake requires the DTE (pc, terminal) to request to send (RTS) and wait for the DCE (modem or other device) to assert clear to send (CTS) before actually sending the data. It does not provide handshaking the other direction. That is generally implemented using data terminal ready (DTR) to hold off the modem until the DTE is ready to accept data. There is no request-response handshake, the modem just needs to verify that the DTE is there and ready.
The following flowchart shows the minimum requirement for RTS/CTS handshake from the point of view of a DTE. Keep in mind that the time between the assertion of RTS and the receipt of CTS may be a minimum of 50mS.
In the real world, you need to have a timer flag in the "wait for CTS" path, or you won't get much done when the cable is unplugged.
When the AVR is acting as a DCE (modem, etc), it will be receiving the RTS signal from the DTE and will respond with CTS given the following:
If all of these things are true, the AVR would assert CTS (logic "0").