Atmeg16 USART communication problem

atmegabatteriesuartusb

In my project, I use a atmega16 to send data to PC via USB to TTL converter at baud rate of 9600 and internal RC of 4Mhz. If I power the atmega16 using my laptop through a usb cable I can receive the data perfectly, but when I power the same using a 9v DC battery and 7805 regulator, I get garbage value on the PC. Please help me out.

Best Answer

You must connect Rx, Tx and ground.
When you supply power from USB then they both PC and mcu operate on a common ground, when you use a battery that ground connection between mcu and PC doesn't exist.

Connect the grounds of USB and battery(-pole) and it should get fixed.