XBEE received data from tx xbee with a data source from PIC.

Hi ,

I met problem.

I send 0x0F for 200 times first, Then send core data.

But in RX XBEE, I didn’t receive 200 0x0F. Sometime 0F is received , sometimes it is not 0F but E8. Sometime the total number is 90, sometime it is around 140.

Who can help me?

What’s the probable reason? In Xbee?

Maybe 200 bytes is overflow in XBEE DI BUFFER?

PIC CODE

list             p=16F877           ; list directive to define processor
#include         <p16f877.inc>      ; processor specific variable definitions


; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

; __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC
; & _WRT_OFF & _LVP_OFF & _CPD_OFF



;***** VARIABLE DEFINITIONS

w_temp           EQU     0x7D       ; variable used for context saving
status_temp      EQU     0x7E       ; variable used for context saving
pclath_temp      EQU     0x7F       ; variable used for context saving

ByteCounter      EQU     0x7C       ;address used for byte counter
ByteCounter1     EQU     0x60

#define          CTS    PORTC,5    ;C5 is connected to XBEE CTS


;**********************************************************************
       ORG       0x000             ; processor reset vector
       goto      Main               ; go to beginning of program
;**********************************************************************
; isr code can go here or be located as a call subroutine elsewhere

       ORG       0x004             ; interrupt vector location
       movwf     w_temp             ; save off current W register contents
       movf      STATUS,w           ; move status register into W register
       movwf     status_temp        ; save off contents of STATUS register
       movf      PCLATH,w           ; move pclath register into w register
       movwf     pclath_temp        ; save off contents of PCLATH register

       movf      pclath_temp,w      ; retrieve copy of PCLATH register
       movwf     PCLATH             ; restore pre-isr PCLATH register contents
       movf      status_temp,w      ; retrieve copy of STATUS register
       movwf     STATUS             ; restore pre-isr STATUS register contents
       swapf     w_temp,f
       swapf     w_temp,w           ; restore pre-isr W register contents
       retfie                       ; return from interrupt

Main:
       banksel   TRISC
       bcf       TRISC,6            ;c6=0 as output
       
; UART module setup
       banksel   SPBRG                   ;115.2k as 0x0A=8.7US
       movlw     0x15                 ; rs232 baud as 57.6k as 0x15
       movwf     SPBRG              ; Enable SPBRG register Baud Rate

       banksel   TXSTA               ; Select memory bank for TXSTA SFR             
       bcf       TXSTA,TX9              ; 6----8-bit transmission
       bsf       TXSTA,TXEN             ; 5----Enable Transmission/set  
       bcf       TXSTA,SYNC             ; 4----Asynchronous mode
       bsf       TXSTA,BRGH             ; 2----High Baud Rate
       

       banksel   RCSTA
       bcf       RCSTA,RX9          ; 6
       bsf       RCSTA,SPEN         ; 7--cause TXIF=1--cause TRMT=1--yes.2cond time
       bsf       RCSTA,CREN         ; 4

;******************Delay for 10ms******************************


      
       
;****************send a 0x0F as start flag repeatly************
Sendrepeat:
       MOVLW     0x0F
       MOVWF     0x61  ;
       MOVLW     0xC8             ;C8=200.  1000 is not allowed in PIC.       
       MOVWF     ByteCounter1      ;maximum is FF in 8 bits.
loop0: 
       MOVF      0x61,0       
       CALL      SerialTX0
       DECFSZ    ByteCounter1,1
       GOTO      loop0
       GOTO      Record        ;????? 

SerialTX0:  
       BANKSEL   PORTC  
       BTFSC     PORTC,5          ;CTS=PORTC,5, TEST C5,  CTS
       GOTO      SerialTX0
       BANKSEL   TXSTA
       BTFSS     TXSTA,TRMT       ;TXSTA,1 =default value is 1.
       GOTO      SerialTX0         ; make sure data transmission is sucessful ?       
       BANKSEL   PIR1
       BTFSS     PIR1,TXIF
       GOTO      SerialTX0
       MOVWF     TXREG
       CALL      Reset0
       return 
Reset0:       
       BANKSEL   RCSTA
       BSF       RCSTA,SPEN    ; enable receive from TXREG to TSR.       
       return
;*****************save data into PIC memory************************
Record:       
       MOVLW     0x0A  ; substitute your code to load W here
       MOVWF     0x50  ;
       MOVLW     0x0B
       MOVWF     0x51  ;
       MOVLW     0x0C
       MOVWF     0x52  ;
       MOVLW     0x0D
       MOVWF     0x53  ;
       MOVLW     0x0E
       MOVWF     0x54  ;
       MOVLW     0x0F
       MOVWF     0x55  ; 

;****************send real data out of PIC**********************  
Send:
       MOVLW     0x06
       MOVWF     ByteCounter  ;ByteCounter=d10
       MOVLW     0x50
       MOVWF     FSR
Loop: 
       MOVF      INDF,0       ; substitute your code to load W here
       CALL      SerialTX
       INCF      FSR,1
       DECFSZ    ByteCounter,1
       GOTO      Loop
       CALL      DelayBig ;
       GOTO      Record
       

SerialTX:      
       BANKSEL   PORTC  
       BTFSC     PORTC,5          ;CTS=PORTC,5, TEST C5,  CTS
       GOTO      SerialTX
       BANKSEL   TXSTA
       BTFSS     TXSTA,TRMT       ;TXSTA,1 =default value is 1.
       GOTO      SerialTX         ; make sure data transmission is sucessful ?       
       BANKSEL   PIR1
       BTFSS     PIR1,TXIF        ;PIR1,4
       goto      SerialTX
       movwf     TXREG            ;cause TRMT=0, FULL. causing 2nd data is not given to TXREG.
       CALL      Reseting
       return

DelayBig:
       BANKSEL   RCSTA    ;05,A5=400u;
       MOVLW     0x05     
       MOVWF     0x20     ;46,F5=10ms.FF,FF=40ms,88,FF=20ms
LOOP2:                    ;;03,C5=O DELAY;
       MOVLW     0xA5     ;08,F5=1ms;88,44=5ms
       MOVWF     0x21     ;04,95=290us;05,95=390u;05,D5=600u;05,A5=400u;
LOOP1:
       DECFSZ    0x21,1
       GOTO      LOOP1
       DECFSZ    0x20,1
       GOTO      LOOP2
       BANKSEL   RCSTA
       BSF       RCSTA,SPEN    ; enable receive from TXREG to TSR.       
       return

Reseting:       
       BANKSEL   RCSTA
       BSF       RCSTA,SPEN    ; enable receive from TXREG to TSR.       
       return

       END
;*********************transmit data finish******************************

Now I use 2 xbees with 2 X-CTU.

I transmit 200 0F followed by 4 “0A0B0C0D0E0F”,so the total is 224bytes. Finally I received 100bytes 0F without the latter, sometimes it is only 4 “0A0B0C0D0E0F” without 0F. Sometimes they are some 0F followed by 4 “0A0B0C0D0E0F”.

and I used broadcast mode. The reason is to make sure without ACK. I guess that broadcast mode is one reason. Because TX XBEE works in this mode, 224bytes are distributed to more than one RX XBEEs. So on my only one RX XBEE, the data is not whole.

What do you think of it?

Any viewpoint is welcome.

I’d like to help, but the code is assembly for a PIC and I graduated from PICs years ago, and rarely use assembly language.

As discussed elsewhere, you must implement flow control using either RTS/CTS or XON/XOFF.

Each 802.15.4 data frame has a payload content of about 108 bytes. Buffering larger volumes of data is the responsibility of the XBee microprocessor application and you don’t say which application you have loaded on the XBees.

yes. you are right. I used CTS judge in PIC code.

And it did work.But now it does not in pcb board.