2
\$\begingroup\$

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)

asked Sep 16, 2014 at 0:19
\$\endgroup\$
5
  • 2
    \$\begingroup\$ Are you tying the grounds of the two devices together? \$\endgroup\$ Commented Sep 16, 2014 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\$ Commented Sep 16, 2014 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\$ Commented Sep 16, 2014 at 1:48
  • \$\begingroup\$ Please show us your code and schematic. \$\endgroup\$ Commented Sep 16, 2014 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\$ Commented Sep 17, 2014 at 13:58

1 Answer 1

1
\$\begingroup\$

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)
answered Sep 17, 2014 at 14:04
\$\endgroup\$
1
  • \$\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\$ Commented Sep 20, 2014 at 11:03

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.