Can you post your complete project? This issue will be outside of your provided code-snippet.
Did it only work when stepping through the code? Or was the difference whether the debugger was attached or not? Did you run the same code (compiled in debug mode) both times?
I cannot step through the code properly due to inteerupt timer going off.
What I did was set break point before sending command to modem and then another at the point where successful response should have occurred.
The program works fine if I program the target and run it with miniprog connected.
How about change your timer to a longer tiem to see if that helps
Also, try to set some delay between sussesive commands, give more time for message to return and decode.
We use a Vreg from the programmer to stop a external WD, do you use the Vreg for anything? also was there any external circuit that would affect XRES?
If the reply is only "OK" and is the first 2 bytes, I think it would return 0, would this be a problem?