[clug] Serial communications between Atmel processors

Alex Satrapa grail at goldweb.com.au
Fri Nov 14 22:06:42 MST 2014

I’d go even babier-steps and connect one ATTiny to a USB/serial converter, then monitor the serial line coming from the PC. When anything is received, flash one LED. When a specific character is received, flash another LED. Output state information through other LEDs, so with two states you’d have two “state” LEDs.

And rather than wiring up a ATTiny on a breadboard, start off with an Arduino. The Uno or Leonardo (or Freetronics Leostick) have a USB-serial adaptor onboard so you can get started with that. Once you know your code is working correctly (because there’s very little hardware to mess up on an Arduino), port it over to the ATTiny.

There is also advice about handling serial communications over on the Arduino forums: http://forum.arduino.cc/index.php?topic=279013.0 (search for “UART” for example).

Whether you’re using Arduino, MHV, or some other set of libraries, it it worth watching for the steps that are tripping up other players in the field.


> On 15 Nov 2014, at 14:59, David Austin <david at d-austin.net> wrote:
> Hi Paul,
> With this sort of thing, I try to take lots of baby steps, relying on the
> LEDs for the debug information at each step.  This means you need
> simple go/no go tests in your code.
> I'm not familiar with the Arduino libraries but my thoughts are:
> 1) do you need to set up the serial port output pin as an output?
> 2) write a simple test for one device that repeatedly writes a
>    char to the serial port and flashes the LED when it does so
> 3) You could try a modified version of 2 and without delay
>     and try chars 0x00 and 0xFF - I'd expect your multimeter
>     may be able to see the DC or AC voltage that results (compare/
>     contrast with the DC/AC voltage of the LED).
> 4) write a simple receive test for the other device that flashes
>    a led when it receives any char & connect to the first
>    device
> Then (and only then) try more complex things with states and such.
> David
> On 15 November 2014 14:46, Paul Wayper <paulway at mabula.net> wrote:
>> Hash: SHA1
>> Hi all,
>> 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:
>> https://github.com/PaulWay/C2B2/blob/master/prototype/Signaller.ino
>> 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
>> the behaviour.
>> 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
>> levels.
>> 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 !
>> Version: GnuPG v1
>> xbwAoMx/6Aw4tzPQTHHf+RZvbgwEKGmm
>> =naFI
>> -----END PGP SIGNATURE-----
>> --
>> linux mailing list
>> linux at lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux
> -- 
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux

More information about the linux mailing list