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– Dan Laks2014年09月16日 00:49:27 +00:00Commented 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\$microtherion– microtherion2014年09月16日 01:27:29 +00:00Commented 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\$Michael Karas– Michael Karas2014年09月16日 01:48:23 +00:00Commented Sep 16, 2014 at 1:48
-
\$\begingroup\$ Please show us your code and schematic. \$\endgroup\$venny– venny2014年09月16日 06:59:31 +00:00Commented 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\$vlad_tepesch– vlad_tepesch2014年09月17日 13:58:58 +00:00Commented Sep 17, 2014 at 13:58
1 Answer 1
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– potato52014年09月20日 11:03:18 +00:00Commented Sep 20, 2014 at 11:03