[clug] Serial communications between Atmel processors

David Austin david at d-austin.net
Fri Nov 14 20:59:45 MST 2014

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

Then (and only then) try more complex things with states and such.


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
> --
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux

More information about the linux mailing list