Trying to use XBee to control a 74HC595 shift register

I wish to set up 4 digital IO pins on my XBee Pro S1 radios (both local and remote radios are identical units, running comms over encrypted API mode) to clock bits into a 74HC595 shift register chip, directly attached to the remote XBee. The are no microcontrollers or any other “intelligent” parts in this circuit, apart from the simplistic C# application that “blindly” controls the local XBee.

X-CTU shows this firmware/config version for BOTH units…
Modem: XBEE (XBP24), Function Set (XBEE PRO 802.15.4) Version (10ED).

I have verified that the encrypted comms is working correctly, but it appears that my IO pins are not responding in the way I would expect given the code I am using to modulate them.

To drive the shift register chip, I’m using D0 as “SI”, D1 as “BarG”, D2 as “RCK” and D3 as"SCK" respectively.

The baud rate is set to 57600 on both radios.

My problem is this…

D3 (SCK) will not toggle properly, as if it is suffering from some weird latency problem. Maybe every 100th pulse is missing (eg a stretched high or low signal) but not with any solid regularity. It seems to happen every few seconds but I cannot force it to happen and can find no way to prevent it.

Following advice from other threads on this forum, I’ve tied both DIN and DOUT hard to ground.

This glitching behaviour means I cannot reliably use the XBee to clock data in to the shift register. The 100mW radio modules have about 12 inches of free air between them - I can’t imagine it’s poor RSSI to blame for this.

Here follows the C# code I am using to modulate the remote radio (by sending 0x17 “Remote AT Command” messages over the local USB-attached XBee). I believe that the code is valid and well formed and not presenting the radios with anything they can’t handle in theory.


 private void cmdShifter_Click(object sender, EventArgs e)
        {
            int i, bits;

            while (true)
            {
                bits = counter & 0xff;
                this.Text = bits.ToString();

                for (i = 0; i < 8; i++)
                {
                    //modulate the SI, SCK pins to clock data out of the XBee into the 74hc595 shift register
                    UAV_AT_Command(new byte[] { (byte)'D', PIN_SI, (bits & 0x01) == 1 ? PIN_ON : PIN_OFF });
                    //Thread.Sleep(100); //milliseconds

                    UAV_AT_Command(new byte[] { (byte)'D', PIN_SCK, PIN_ON });
                    Thread.Sleep(10); //milliseconds

                    UAV_AT_Command(new byte[] { (byte)'D', PIN_SCK, PIN_OFF });
                    Thread.Sleep(10); //milliseconds

                    bits >>= 1; //put next bit into position for the following iteration of the loop
                }
                UAV_AT_Command(new byte[] { (byte)'D', PIN_RCK, PIN_ON });
                UAV_AT_Command(new byte[] { (byte)'D', PIN_RCK, PIN_OFF });
                //Thread.Sleep(100);//milliseconds

                counter++;
            }
        }

Each bit transition is a separate message over the radio (one message to alter SI, another to alter SCK, yet another to alter RCK…) 90% of messages work fine but every so often it looks like messages are being ignored for no reason that I can find. I’ve checked the power supply and tried replacing it with different batteries and wallwarts - I think the power is OK. i’ve tried various combinations of decoupling caps all over the circuit (on all sensitive parts of the system) simultaneously.

I am completely at a loss as to what might be causing this weird loss of data.

I need someone to cast a fresh pair of eyes over this and throw me a lifeline.

Many thanks.

W.