Can't use AT command from PIC16f628 with Xbee Pro

I use Xbee Pro Series1 with PIC16f628 and CSS compiler. Now I have to write AT command from X-CTU befor connect to microcontroller.I want to set AT command from microcontroller but it don’t connect when I sent AT command from microcontroller .I don’t know why.May be I have to set some thing at Xbee befor use microcontroller send AT command to Xbee This is my code

#include <16f628A.h>
#include 

#USE delay(clock=4000000)
#fuses XT,NOWDT,PUT,NOPROTECT,BROWNOUT,NOCPD
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1)

void delay(long z)
{  for(z=z;z>0;z--);
}

void main(void)
{
printf("+++");
putc(0x0d);
delay(100000);
printf("ATGT%u",(50));
putc(0x0d);
delay(100000);
printf("ATCH11");
putc(0x0d);
delay(100000);
printf("ATID100");
putc(0x0d);
delay(100000);
printf("ATCE0");
putc(0x0d);
delay(100000);
printf("ATBD3");
putc(0x0d);
delay(100000);
printf("ATSM%d",0);
putc(0x0d);
delay(100000);
printf("ATRO%d",0x00);
putc(0x0d);
delay(100000);
printf("ATDH0");
putc(0x0d);
delay(100000);
printf("ATDL%d",0);
putc(0x0d);
delay(100000);
printf("ATMY1");
putc(0x0d);
delay(100000);
printf("ATWR");
putc(0x0d);
delay(100000);
printf("ATCN");
putc(0x0d);
delay(100000);

st:
   printf("hello world");
   putc(0x0d);
   putc(0x0a);

   delay(30000); delay(30000);
   delay(30000); delay(30000);  
 
goto st;
}

Since your request is more programming-advice related, rather than specific to the XBee 802.15.4, I’ve moved your thread. Hopefully you’ll have more luck finding an answer in this forum.

I don’t have much familiarity here, so my suggestion could be off, but have you tried sending an ATAC command after ATWR in order to apply the changes?

Chris