PIC or xbee times out after Tx 504 bytes


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2009
    Posts
    17

    Default PIC or xbee times out after Tx 504 bytes

    Code:
    '###############################################
    '#
    '# program to test Tx & Rx API packets on 
    '#  xb24 series 1 units. 
    '#
    '# host mcu's=  pic16f88
    '#
    '###############################################
    
    
    '---[set fuses]---------------------------------
    
    'Program Configuration Register 1
    @ __CONFIG    _CONFIG1,  _HS_OSC & _DEBUG_OFF & _WDT_ON & _LVP_OFF & _CP_ALL & _CPD_ON & _BODEN_ON & _MCLR_ON & _PWRTE_ON & _WRT_PROTECT_OFF
    
    ;Program Configuration Register 2
    @ __CONFIG    _CONFIG2, _IESO_OFF & _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 & Rx, sets SPEN & CREN & OERR
    DEFINE HSER_TXSTA 24h ' Enable Tx HS, TXEN=1 & 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 & Checksum  'remove values > 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

    mcu=pic16f88
    xbee=xb24

    i'm sending a string then checksum from the host pic16f88 to a xbee and that xbee sends it to another xbee. somewhere around 34-35 iterations for a total of 504 bytes the xbee's stop sending/recieving.

    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.

    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 my pic16f88 or my program/fuses or both.

    any thoughts on why this is happening?

    thx
    archendekta

  2. #2
    Join Date
    Jan 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    finally got the setup to work.

    can't say for sure what exactly what was causing the problem. reflashed all the xbee's to their default and reset a few parameters and all is working fine.

    code was fine and the pic's were fine.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    From a very preliminary test I did, the receiver of the XBees is very susceptible to saturation. I had to move the modules 10-15 meters away to work properly. I know this seems irrelevant ot your case but just keep it in mind.

    Ioannis

    P.S. Are you going to make a ZigBee network?

  4. #4
    Join Date
    Jan 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    the distance factor could have been an issue and one to keep in mind. thanks.

    i have the xbp24-zb's for another project for a ZB network.

    this current one is using the "802.15.4 series I" xbee's.

    i wonder if there is a config parameter that helps with the saturation issue for short distances? would you know?

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Just drop the RF power to the minimum. But ifdistance is less that 5 meters the receivers are saturated again.

    Ioannis

  6. #6
    Join Date
    Jan 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    0= -10dBm
    1= -6dBm
    2= -4dBM
    3= -2dBm
    4= 0dBm

    so with these 802.15.4 series I, lowest would be -10dBm, yes?

    good to know, thx

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Yes, that's right

    Ioannis

Similar Threads

  1. Replies: 67
    Last Post: - 8th December 2009, 02:27
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. PIC Basic PRO 16F877 USART Interrupt TX
    By BigH in forum Serial
    Replies: 8
    Last Post: - 9th January 2006, 23:26
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts