[clug] Serial communications between Atmel processors
paulway at mabula.net
Fri Nov 14 20:46:31 MST 2014
-----BEGIN PGP SIGNED MESSAGE-----
I've got a fairly specific programming question - if I'd thought about it I
could have had the programming SIG to talk about it, but my brain was too
slow for that.
I'm trying to get two (or more) ATTiny85s to talk to eachother. I'm using
the standard Arduino environment and their SoftwareSerial library. The code
is fairly simple - it sets up the serial connection and starts in state '1'.
If the serial port has received something, if it's a '1' then it sends a '2',
otherwise it sends a '1'. Then if the state is '1' it turns on LED 1 and
turns off LED 2 and vice versa for state '2'.
The basic circuit is each ATTiny has PB0 and PB1 (pins 5 and 6) connected to
two LEDS; PB2 is RX and PB3 is TX (pins 7 and 3). They use a common ground
and VCC (which is a Lithium polymer battery, currently at about 3.8V) and
the TX of one ATTiny is connected to the RX of the other. The code is at:
The problem is that it starts up and both boards turn LED 1 on and 2 off,
and stay like that permanently.
I've put a delay between reading the character off the available port and
sending the response, but that doesn't change anything. I started with snd
and rcv instantiated within the loop, but they're now global, and I started
with only case 1 and the default and now I have case 1, 2, and default being
different (as you can see in the code). None of those changes have changed
So either the serial communication isn't establishing itself, or the ATTiny
isn't actually capable of this (despite, AFAICS, this being what the
SoftwareSerial library is for) so it's never going to work. I don't have a
logic analyser or oscilloscope (I've looked at the http://www.osciprime.com/
- - any opinions). My next debugging options are to put an LED between each
transmit pin and the receive pin on the other ATTiny, to see if they're
actually doing anything, but I didn't know if that would interfere with line
My next debugging step is to put LEDs in the path between TX and RX and see
if there's any activity there.
Any advice on what I'm doing wrong here, or how to do it better, would be
greatly appreciated !
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
-----END PGP SIGNATURE-----
More information about the linux