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)

  • 2
    \$\begingroup\$ Are you tying the grounds of the two devices together? \$\endgroup\$ – Dan Laks Sep 16 '14 at 0:49
  • \$\begingroup\$ How do you set the baud rate? Specifically, did you take into account that e.g. an Arduino core does NOT work for your particular clock frequency? \$\endgroup\$ – microtherion Sep 16 '14 at 1:27
  • 1
    \$\begingroup\$ Did you make the mistake of connecting the TxD of Avr to TxD of FTDI - and connecting RxD of Avr to RxD of FTDI? It is a common mistake. \$\endgroup\$ – Michael Karas Sep 16 '14 at 1:48
  • \$\begingroup\$ Please show us your code and schematic. \$\endgroup\$ – venny Sep 16 '14 at 6:59
  • \$\begingroup\$ as Michael Karas mentions the mistake. It should be noted that you always should look carefully of the descriptions/connections on the boards. sometimes the pin labels on boards did not name the own pins but the lines that have to connected to. so the RX pin is labeled with TX and vice versa. \$\endgroup\$ – vlad_tepesch Sep 17 '14 at 13:58

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)
  • \$\begingroup\$ Checked all those things (RX-TX connections took some trial and error, but they are correct). I chose the crystal to get an error-free baud rate. A friend tried the same thing with the internal oscillator, and discovered it was because the internal oscillator had loads of error ... dunno how that works for crystal. \$\endgroup\$ – potato5 Sep 20 '14 at 11:03

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.