Can't get AT command responses

Hello,

I’ve been using XBee Pro 892.15 modules in several products, driven by an 8051 variant running Keil C51. Good success accessing the AT command set, and very satisfied with performance.

A new project uses a Microchip PIC18F87J72 processor, running with Microchip’s MCC18 compiler. My first problem was that their printf() function is broken - so I wrote workaround code doing puts emulations. The code seems to work fine, according to my serial output buffer.

Now, for the issue - as a modem, the XBee module works perfectly. I receive and transmit data flawlessly. When I want to enter AT command mode, things go bad rapidly.

I ported the working code from the 8051 project to Microchip C18, and things are happening that I can’t attribute to the code. I’ve got the baud rate set to 38,400, and it is accurate. Guard times are set to values that seem to work for this application.

On startup, I go into AT command mode and look for “OK” to verify the module is installed and working, then send ATCN to get back to modem mode.

When I send the “+++” string after the guard time expires, and then wait another guard time, the modem transmits “++” and then the closing ATCN command to my receiving module. If I instead send “+++X” with any ASCII character appended as the ‘X’, it goes into command mode and responds with “OK”. The serial output buffer shows the sent characters in either case, and they are correct.

Sending a request for data returns an “OK”, but no data field. This is reliable.

The modules have version 10E6 firmware. The module is never put to sleep in this application.

It’s maddening that everything works fine in one product, but not here.

Sounds like a UART speed issue. I assume you are using some form of interrupt driven send? This might make the TX stream ckind of choppy. In other words, the Xbee might see a pause at an incovient location if you send AAABBB+++CCCDDD.

Is serial your highest priority? Worstcase, your code might need to watch for the “X+++X” and pause, insuring the 5 bytes go without pause.

Personally, I always use API format on a ‘smart’ device with XBee, and only AT mode on dumb Xbee-unaware device.

If you monitor the serial link between the Microchip C18 and the XBee, what do you see it sending? I’m guessing that there’s a problem in your serial transmit routines if you need an extra character in your escape sequence – a character that the other device never sees.

UART speed is right on the button. When I send normal data via the modem, everything is fine.

I use different code to send AT commands, and there’s something really subtle wrong in there. I looked at the normal data stream earlier, and all characters get sent out the UART. When I send “+++”, I use a different function, which I thought was using the same logic as for data - but I see I am losing the last character of every string. This is why “+++X” wakes up the AT command mode, but “+++” fails. The module only sees “++”.

It’s hiding in my code, and it’s sneaky. It will probably turn out to be something really stupid.

Thanks for the support!

Chuck Kuecker