chipKIT® Development Platform

Inspired by Arduino™

Hang on data in from XBee

Created Thu, 10 Apr 2014 02:33:56 +0000 by ServoHawk2


Thu, 10 Apr 2014 02:33:56 +0000


I'm trying to create a simple loop-back test with my XBee Series 1 in transparent mode. XBee to PC is working great in one direction, all baud rates. In fact, I'm pushing 7500 sensor readings (35k) a minute @115kbaud over 150' - not a glitch in the single direction.

BUT, the MAX32 hangs upon arrival of data - every time, instantly. I stripped down to code to the basics to unit-test it.

Code (below) is straight-forward. Interestingly, the same code works if I use only Serial (in and out the USB port). Using Serial1 (below) or Serial2 or Serial3 with Xbee causes a hang upon receipt of the new data. I have tried all baud rates, same issue (sends fine, hangs on first receive). I had a scope on the RX1-RX3 lines and see the new data arriving - then bang - it crashes. Appropriate data signals are being delivered, so I can count out the XBee configuration as being an issue. Most basic test - send a single character/byte - hang, so it's not DI buffer over-run.

This test happens to be in Serial, out Serial1 - because I just saw in/out Serial working fine. I have also tried in/out on each of Serial1-3 - same hang behavior, all baud rates.

It is as if the DI buffer/queue is not established and I'm triggering a memory fault when the first character arrives causing a system halt. I lack the diagnostics to get within the Arduino logic.

Probably something simple as I am SURE tons of folks are doing this!

Many thanks for insight, -john

// MAX32
// Loop-back test

unsigned long tstart;
unsigned long ttotal = 0;

int loop_count = 0;
char inByte = 0;

void setup() {
    // Communications
    Serial.begin(115200);    // This sets up a serial connection
    Serial1.begin(115200);   // This sets up XBee connection
    delay (2000);          // allow serial line setup       
    Serial1.write("@");   // verify Serial1 operational

void loop() {
    // read from Serial, echo to Serial1:
    loop_count += 1;
    if (( loop_count % 100) == 0)
        Serial.write("*");                 // life indicator
    if (Serial1.available()) {     //IF (.available) - hangs HERE
        tstart = micros();               
        while (Serial1.available()) {
            inByte =;
        ttotal = micros() - tstart;
        Serial.print( ttotal);


Thu, 10 Apr 2014 07:51:36 +0000

Let me guess... MPIDE version 20130715? Upgrade.



Thu, 10 Apr 2014 21:19:04 +0000


BINGO! That was it! I probably wasted five hours trying to get it to work with all my experimental permutations.

Many thanks to you, majenko, for sharing this insight! -john