Author Topic: Problem in receiving data: xbee pro s2b  (Read 1260 times)

0 Members and 1 Guest are viewing this topic.

Offline embedded.world@aol.comTopic starter

  • Contributor
  • Posts: 19
Problem in receiving data: xbee pro s2b
« on: July 01, 2014, 11:24:19 am »
I have to transfer data between two xbee modules wirelessly.
I don't have any setup to configure xbee by x-ctu
I have to configure xbee on the run with the help of microcontroller.
I am using Xbee Pro S2B.


1.Since xbee pro s2b don't let to set ""atmy" to I don't understand how to set xbee own address.

2. Below are code I have used for tx & rx.
In both codes I am able to configure xbee as per the code. I get ok reeponse from all the commands.
Tx code transmit data after that. But problem is rx don't receive data??

I have try to set different destination address of xbee's, same address but no help??


3. Tx code is below:
Code: [Select]
void code_tx(void)
{
/*
CPU = 16Mhz
Uart: 9600bps, 8 bits , 1 stop , no parity

MCU to XBEE Pro S2b connections: Vcc, Dout,Din,Sleep,GNd
                                 Rest all pins on xbee are unconnected

 */


    XBEE_PIN_WAKEUP();
    wait_delay_us(20000);
   
    while( 'F' == response )
    {
    /* send a dummy character */
        xbee_uart_tx_string((u8_t *)("X"));     
   
    /* guard time */   
        wait_delay_us(3000000);
   
    /* send AT command */   
        xbee_uart_tx_string(("+++"));
        response = xbee_response_ok_check();     

        if( 'T' == response )
        {
        /* factory defaukt */
           
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atre"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }

        if( 'T' == response )
        {
        /* send destination address */
            wait_delay_us(200000);               
           
            xbee_uart_tx_string((u8_t *)("atdh0"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }           
       
        if( 'T' == response )
        {
        /* send destination address */
            wait_delay_us(200000);           
           
            xbee_uart_tx_string("atdlffff"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }   
       
        if( 'T' == response )
        {
        /* send ID address */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atid2244"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }                           
       
        if( 'T' == response )
        {
        /* sleep mode setting */
            wait_delay_us(200000);           
           
            xbee_uart_tx_string(("atsm1"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }           
       
        if( 'T' == response )
        {
        /* write my address in memory */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atd70"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }         

        if( 'T' == response )
        {
        /* write my address in memory */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atwr"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        } 
       
        if( 'T' == response )
        {
        /* exit AT mode */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atcn"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }             
       
       
    /* if failed then restart */
        if( 'F' == response )
        {
            for(cnt = 0 ; cnt < 100 ; cnt++)
            wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US);
        }   
       
    }
       
/* SLEEP MODE */
    XBEE_PIN_SLEEP();


while(1)
{
XBEE_PIN_WAKEUP();
wait_delay_us(10000);
xbee_uart_tx_string(("HELLO WORLD"));
XBEE_PIN_SLEEP();

wait_delay_us(4000000);

}


}



3. Rx code is below:

Code: [Select]
void code_rx(void)
{

/*
CPU = 16Mhz
Uart: 9600bps, 8 bits , 1 stop , no parity

MCU to XBEE Pro S2b connections: Vcc, Dout,Din,GNd
                                 Rest all pins on xbee are unconnected

 */
   
    while( 'F' == response )
    {
    /* send a dummy character */
        xbee_uart_tx_string((u8_t *)("X"));     
   
    /* guard time */   
        wait_delay_us(3000000);
   
    /* send AT command */   
        xbee_uart_tx_string(("+++"));
        response = xbee_response_ok_check();     

        if( 'T' == response )
        {
        /* factory defaukt */
           
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atre"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }

        if( 'T' == response )
        {
        /* send destination address */
            wait_delay_us(200000);               
           
            xbee_uart_tx_string((u8_t *)("atdh0"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }           
       
        if( 'T' == response )
        {
        /* send destination address */
            wait_delay_us(200000);           
           
            xbee_uart_tx_string("atdlffff"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }   
       
        if( 'T' == response )
        {
        /* send ID address */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atid2244"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }                           
       
        if( 'T' == response )
        {
        /* write my address in memory */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atwr"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        } 
       
        if( 'T' == response )
        {
        /* exit AT mode */
            wait_delay_us(200000);             
           
            xbee_uart_tx_string(("atcn"));
            xbee_uart_tx_data(0x0d);
            response = xbee_response_ok_check();
        }             
       
       
    /* if failed then restart */
        if( 'F' == response )
        {
            for(cnt = 0 ; cnt < 100 ; cnt++)
            wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US);
        }   
       
    }


while(1)
{
xbee_response_check();

}


}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf