I am trying to interface my ATmega chips to the computer using a serial interface. I have read that this can be done directly by connecting the appropriate pin between the chips and the serial pin. But it is advised that I use a MAX232 chip. What is the purpose of this chip and do I really need to use it?
I ask this because in a project I am making, there is a big size constraint and the chip might take up valuable space.
If you need to connect the AVR to the computer using the serial port and a "standard" DB9-DB9 serial cable, yes, you need to use an RS232 transceiver in circuit. The AVR's UART outputs 0-5V signaling. The RS232 spec is +/-15V signaling, and I believe it's also "inverted" with compared to UART signaling. You don't have to use specifically the MAX232, but you do have to use a RS232 transceiver. These chips (plus some external capacitors) handle the voltage level conversions (via charge pumping) in either direction as well as the signal inversion, and act as "line drivers" driving longer lengths of wire allowed by the RS232 standard.
Alternatively, you can use a cable that includes such a transceiver circuit embedded in the DB9 shell if you are space constrained on your board. Yet another alternative involving a cable is to use a cable that includes an FTDI FT232 chip in it, which has the advantage of making it look like a COM port over USB to the computer, but you're looking at upwards of $15 for that cable.