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

Adam Lawrence
33.6k3 gold badges60 silver badges110 bronze badges
asked Dec 2, 2015 at 9:38
\$\endgroup\$
8
  • \$\begingroup\$ Is the chip being supplied sufficient current at the appropriate voltages? \$\endgroup\$ Commented Dec 2, 2015 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\$ Commented Dec 2, 2015 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\$ Commented Dec 2, 2015 at 14:46
  • \$\begingroup\$ @Austin we tried pulling up the RESET line both with and without a pullup, no change in behavior. \$\endgroup\$ Commented Dec 2, 2015 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\$ Commented Dec 2, 2015 at 15:04

1 Answer 1

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

Adam Lawrence
33.6k3 gold badges60 silver badges110 bronze badges
answered Dec 2, 2015 at 21:36
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.