Electronic – AVR external crystal not working with UART

avrcrystalftdiuart

So I have an ATmega328P with a 14.7456MHz external crystal, full-swing settings, and I'm trying to talk to my mac via UART and an FTDI friend-type device.

If I connect AVR Tx to AVR Rx, then all bytes come through perfectly (I can view it on some 7-set displays). If I connect FTDI Rx to FTDI Tx, then all bytes come through perfectly (viewed on Arduino serial monitor). The baud rates of both devices are the same.

However, when I connect them together …

Serial monitor gets data (scroll bar appears and starts scrolling across), but no characters are displayed. It's as if they are all spaces (I send 'a', or an arbitrary 8 bit number). If I select half the baud rate, then weird characters appear, but not what I send.

AVR receives characters (receive interrupt fires), but what it receives is either 0, or the same number (eg. 173, but it seems rather random) for any character I send.

I've googled and googled, and have found no solution to this. Any ideas? Help on this is much appreciated. (hopefully I've provided enough information)

Best Answer

double check the following things:

  • is your baud rate calculation/register setting correct
  • does your crystal support the selected baud rate (is the baudrate error below the critical threshold)
  • is your F_CPU setting correct (calculation of baud rate register value may depend on this)
  • have you correctly set your fuses to use the crystal
  • have you mixed up RX-TX line connections (look at my comment above)