# xbee times out after Tx ~504 bytes

**URL:** <https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232>\
**Category:** XBee - 802.15.4\
**Created:** [November 16, 2009, 8:55am UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232 "2009-11-16T08:55:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eMLz](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@eMLz](https://forums.digi.com/u/eMLz)\
**Post date:** [November 16, 2009, 8:55am UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232/1 "2009-11-16T08:55:03Z")

</div>

mcu=pic16f88  
xbee=xb24 series I

i’m sending a string then checksum from the host pic16f88 to a xbee and that xbee sends it to another xbee on the dev board. somewhere around a total of approx 504 bytes the xbee’s stop sending/recieving. the association light hangs at this time also.

the pic is still sending the string out as i can see this with a LCD connected to the Tx pin on the sending host and the debug pin sends to a term window fine.

i’ve tried different baud rates on the pic & xbee but that didn’t seem to help with this particular issue.

Now, i can use two xbib dev boards connected to my computer with one of the xbee’s on each and send the same API packet with no issues.

so i’m leaning towards the problem is a timing issue with my pic16f88 or my program/fuses or both.

i’ve tried external resonators from 8MHz-20MHz. I have 22pF caps on the external crystals. I have tried the internal RC. but still, the issue remains.

any thoughts on why this is happening?

thx

'## code is in pic basic using mplab/mpasm

```auto

'###############################################
'#
'# program to test Tx &amp; Rx API packets on 
'# xb24 series 1 units. 
'#
'# host mcu's= pic16f88
'#
'###############################################

'---[set fuses]---------------------------------

'Program Configuration Register 1
@ __CONFIG _CONFIG1, _HS_OSC &amp; _DEBUG_OFF &amp; _WDT_ON &amp; _LVP_OFF &amp; _CP_ALL &amp; _CPD_ON &amp; _BODEN_ON &amp; _MCLR_ON &amp; _PWRTE_ON &amp; _WRT_PROTECT_OFF

;Program Configuration Register 2
@ __CONFIG _CONFIG2, _IESO_OFF &amp; _FCMEN_OFF

'---[includes----]-------------------------------

INCLUDE "bs2defs.bas"

'---[debug defines]-------------------------------

DEFINE DEBUG_REG PORTA
DEFINE DEBUG_BIT 2
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1

'---[defines]--------------------------------------

DEFINE OSC 8

'DEFINE HSER_RCSTA 90h 
DEFINE HSER_RCSTA 92h ' Enable serial ports Tx &amp; Rx, sets SPEN &amp; CREN &amp; OERR
DEFINE HSER_TXSTA 24h ' Enable Tx HS, TXEN=1 &amp; BRGH=1
DEFINE HSER_BAUD 9600 ' set baud and compiler will auto calc HSER_SPBRG
DEFINE HSER_CLROERR 1 ' Clear overflow automatically

ANSEL=0  
ADCON0=0
ADCON1=7
CMCON=7

'---[contants]---------------------------------------

LF CON 10
CR CON 13
MAX_DATA_LEN CON 12

'-----------------------------------------------------------------------

BLINK_PA1 VAR portA.1    
BLINK_PB1 VAR portB.1 'to show sending serial data

TX_APIPacket VAR byte[14]
Counter VAR byte
Checksum VAR byte
Ndx VAR byte

'-----------------------------------------------------------------------
       
INIT:
  Clear
  gosub FILL_API_PACKET 

MAIN:
   FOR counter=0 to 35
      gosub sub_Test_Tx_API_Frame
   next counter
   goto MAIN

sub_Test_Tx_API_Frame:
    gosub sub_CALC_Checksum

    'send debug to realterm window
    Debug "TX= ",str TX_APIPacket\13," ", hex checksum, " [Cnt: ",dec counter,CR
 
    hserout [str TX_APIPacket\13, checksum]  
    gosub sub_BLINK_PB1 'show pic is alive
    pause 500
RETURN

FILL_API_PACKET:
   TX_APIPacket(0)=$7E  
   TX_APIPacket(1)=$00   
   TX_APIPacket(2)=$0A   
   TX_APIPacket(3)=$01   
   TX_APIPacket(4)=$01 'API frame ID
   TX_APIPacket(5)=$50 'DL addr
   TX_APIPacket(6)=$01 'DL addr
   TX_APIPacket(7)=$00 'option
   TX_APIPacket(8)=$48 'H
   TX_APIPacket(9)=$65 'E
   TX_APIPacket(10)=$6c 'L
   TX_APIPacket(11)=$6c 'L  
   TX_APIPacket(12)=$6f 'O
RETURN   

sub_CALC_Checksum:
    Checksum = 0
    for Ndx = 3 to MAX_DATA_LEN
       Checksum = Checksum + TX_APIPacket(Ndx)
    next 
    Checksum = $FF &amp; Checksum 'remove values &gt; 1 byte
    Checksum = $FF - Checksum '2's compliment
RETURN

sub_BLINK_PA1:
  High BLINK_PA1
  pause 200
  low BLINK_PA1
  PAUSE 200
RETURN

sub_BLINK_PB1: 
  High BLINK_PB1
  pause 200
  low BLINK_PB1
  PAUSE 200
RETURN

END                  

```

---

<div class="post-metadata">

**Author:** ![johnf](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@johnf](https://forums.digi.com/u/johnf)\
**Post date:** [November 16, 2009, 6:45pm UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232/2 "2009-11-16T18:45:06Z")

</div>

I’m not familiar with that version of Basic, but I don’t see anything obviously wrong with the code.

Have you checked Q7 in the Unofficial FAQ?

[http://www.jsjf.demon.co.uk/xbee/faq.htm](http://www.jsjf.demon.co.uk/xbee/faq.htm)

---

<div class="post-metadata">

**Author:** ![eMLz](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@eMLz](https://forums.digi.com/u/eMLz)\
**Post date:** [November 17, 2009, 3:25am UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232/3 "2009-11-17T03:25:34Z")

</div>

i’ll take a look at that and see.

it happens on either breadboard with one using a droids.it breakout board and the other using a sparkfun breakout board. i did that just to test the 3.3v requirement on the xbee’s. same problem.

thx

---

<div class="post-metadata">

**Author:** ![waltr](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@waltr](https://forums.digi.com/u/waltr)\
**Post date:** [November 18, 2009, 6:42pm UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232/4 "2009-11-18T18:42:17Z")

</div>

I’d check the CTS signal from the XBee with a scope. It may be possible that you are overflowing the XBee’s serial receive buffer.

---

<div class="post-metadata">

**Author:** ![eMLz](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@eMLz](https://forums.digi.com/u/eMLz)\
**Post date:** [November 19, 2009, 8:05am UTC](https://forums.digi.com/t/xbee-times-out-after-tx-504-bytes/1232/5 "2009-11-19T08:05:57Z")

</div>

thanks john for the link. i actually have that on my wall from one of your other posts. it helped to revisit

waltr, i don’t have a scope. that problem i had written down in my notes earlier to check on. looked at some config setings on the xbee’s for that.

although i have each xbee’s profile saved so i can do diff’s easily to quickly see each unit’s config i really couldn’t see anything out of place…although my knowledge base currently is narrow with the xbee’s.

i flashed each one back to the default factory settings.

then started with 2 xbees for 16bit addressing, and that worked. then onto 64bit addressing and that worked. then one coordinator and a few end devices and they worked.

using either a 4mhz, 8mhz external resonator all at 9600 baud. so far so good. like they are working flawlessly.

no change to my code. works as expected.

other than that, i can’t say for certain what wasn’t quite right.

thanks for helping though. i think i’ll splurge for a software app for scoping. i can see where that would have helped quite a bit.
