Only one code is used for both transmitter and receiver part which is given below .In this program I have included avr gcc library for USART written by Peter Fleury you can find original file with documentation here or download this library in this link . uartlibrary
In simplex mode of communication there is only one way of communication . Only one microcontroller can be made as transmitter while other microcontroller must receive that data sent from transmitter . In half duplex mode we can make both microcontroller as transmitter as well as receiver but only one at a time . It means both microcontroller cannot transmit or receive data simultaneously as shown in figure below .
The half duplex mode of communication in avr is similar to that of simplex mode , you do not need to initialize any extra register set or reset any bit of other register , This is how you program your microcontroller . Now let us describe what we have done in above project .
We have included USART library where as in code we simply call a function to initialize with arguments baud rate and frequency of CPU .After pressing the button we transmit character 'c' .And in receiving part we check the ring buffer ( Ring buffer is a component of AVR microcontroller where data is always present and generally ring buffer is used for data reception in serial rx interrupt routine ) If there is data available in ring buffer then we do work according to the transmitted character 'c' .