1
\$\begingroup\$

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).

\$\endgroup\$
  • \$\begingroup\$ Is the chip being supplied sufficient current at the appropriate voltages? \$\endgroup\$ – Ignacio Vazquez-Abrams Dec 2 '15 at 9:48
  • \$\begingroup\$ 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. \$\endgroup\$ – Austin Dec 2 '15 at 10:09
  • \$\begingroup\$ 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! \$\endgroup\$ – bigjosh Dec 2 '15 at 14:46
  • \$\begingroup\$ @Austin we tried pulling up the RESET line both with and without a pullup, no change in behavior. \$\endgroup\$ – scottinthebooth Dec 2 '15 at 15:03
  • \$\begingroup\$ 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! \$\endgroup\$ – scottinthebooth Dec 2 '15 at 15:04
2
\$\begingroup\$

The problem was solved by adding a .1uF capacitor on the output of the 7805. This keeps the power stable and avoids the garbled serial we were seeing

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.