# AVR Atmega164P UART / ISP programmer problem

I am having a problem with the USART on an Atmega164P. When the ISP programmer is connected everything works fine. If I disconnect the programmer then all I get is garbled serial and the chip won't respond to characters that I send. Here's the code

void USART_Transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSR0A & (1<<UDRE0)) )
;
/* Put data into buffer, sends the data */
UDR0 = data;
}

void sendString ( unsigned char str[16] )
{
int i=0;
for ( i = 0 ; i < len ( str ) ; i ++ )
{
USART_Transmit ( str [ i ] );
}
}


Assorted functions call sendString and they all work fine until the programmer is disconnected. Then nothing works.

The connection to the PC is a USB->TTL Serial adapter.

On the electrical side I've checked for common ground / ground loops, different voltages on the programming pins, and other inputs that might be affecting the programming pins. Nothing is connected to the programming pins except the programmer itself.

We also tried plugging the programmer into a USB wall charger. This made the chip function as expected, as did connecting it to a laptop running only on battery.

We also connected the RESET line to VCC both with and without a pullup resistor, neither of those tests yielded successful results (still received garbled serial).

• Is the chip being supplied sufficient current at the appropriate voltages? – Ignacio Vazquez-Abrams Dec 2 '15 at 9:48
• Is the chip resetting? The reset pin has no internal pull-up and could be floating, resetting the chip in the middle of the transmission. – Austin Dec 2 '15 at 10:09
• I agree with @IgnacioVazquez-Abrams. Sound like the chip is getting powered via the ISP so when that is unplugged the Vcc is dropping too low. You can test by only connecting the Vcc and ground lines from the ISP to the AVR. If the serial still works then it is almost certainly a power problem. If not, report back because that would be interesting! – bigjosh Dec 2 '15 at 14:46
• @Austin we tried pulling up the RESET line both with and without a pullup, no change in behavior. – scottinthebooth Dec 2 '15 at 15:03
• IgnacioVazquez-Abrams and bigjosh (it won't let me tag two of you) I'll try only connecting the VCC and GND lines on the header, see what happens and let you know! – scottinthebooth Dec 2 '15 at 15:04