Hi, my modem is GR64_0001, i test it with windows hyperterminal and it’s ok, i made the code on c18 compiler and i found that the pic don’t send the right \r. I made several test with \r, \n, \r\n, \n\r, and nothing. The pic receives Restart and show it in a LCD, sends AT and the eco works, but when a send the CR returns nothing.
I changed the ATQ and ATE, and ATS3 to 45, aTS4 to 40, that to see if there was any change but nothing again.
My question is if the c18 compiler works to this application or not.
If anybody have any idea, i’ll really appreciate it.
Thanks a lot.
while(!DataRdyUSART());
getsUSART(restart,11);//receive restart with \r\n
Delay10KTCYx(50);
while(BusyUSART());
putrsUSART(“AT\r”);//i tried CR after receive the eco too.
Delay10KTCYx(50);
sure, i wrote the complete code to send a sms, and it appears complete on windows hyperterminal including the CR, that the reason i’m worry, i know the pic, the compiler and the gr64 works, but when i tried to send it to module, don’t send the sms.
The trouble with Hypoterminal is that you can’t tell if it is really a CR, or something else that just happens to cause Hypoterminal to move its cursor to the start of the line…
I tested too, i made a code to put each caracter from the hyperterminal to pic’s portb, It showed 0x0d, but the problem is that, i don’t know if when i press Enter sends just CR or CR and LF. I don’t know if the pic’s usart sends a copy of string, i made a code to write on Hyperterminal, pic reads the string and then writes the GR64 but nothing, i think that the problem is the pic or the compiler changes the value of the char CR.
If you suspect the PIC or hyperterminal changes the CR LF, why not just send the actual characters for carriage return and line feed. (0x0D and 0x0A instead of “\r\n”). That way you are sure you are sending the right characters.
For testing what characters are actually being shuffled up and down the serial line, I use Realterm http://realterm.sourceforge.net/. It can display the data as ASCII, HEX, or a combination of both. Realterm is a little funny to use, but once you’re used to it, it is a very useful tool.
For general purpose terminal, I use TeraTerm Pro http://ttssh2.sourceforge.jp/. TeraTerm will do either Telnet or Serial connections, is smart enough to display only the COM ports available and not in use in the system (handy if you have a number of different USB to Serial adapters), and has a simple Macro/Scripting language.
However, the following, while a little long winded and probably inefficient will definitely output the individual CR & LF characters using printf:
printf("myString%c%c", 0x0D, 0x0A);
BTW, which version of the C18 compiler are you using? There are different optimizations available depending on if you are using the free trial version or have paid for the full licence.
Just for the sake of completeness, that may be true of the PIC libraries (I have no idea), but it’s not universally true.
The Keil C51 libraries, at least, apply the “new-line” translation to the output from printf - so “new-lines” can still get translated irrespective of what tricks you use with printf…
It is the default implementation of putchar (provided by Keil) that does the translation:
/*
* putchar (full version): expands '\n' into CR LF and handles
* XON/XOFF (Ctrl+S/Ctrl+Q) protocol
*/
char putchar (char c) {
if (c == '\n') {
if (RI) {
if (SBUF == XOFF) {
do {
RI = 0;
while (!RI);
}
while (SBUF != XON);
RI = 0;
}
}
while (!TI);
TI = 0;
SBUF = 0x0d; /* output CR */
}
if (RI) {
if (SBUF == XOFF) {
do {
RI = 0;
while (!RI);
}
while (SBUF != XON);
RI = 0;
}
}
while (!TI);
TI = 0;
return (SBUF = c);
}
so anything else that goes via putchar will also do the translation.
I´m working now with Realterm, it is better than hyperterminal, i’m using a full version c18 compiler with upgrade “MPLAB-C18-Upgrade-v3_20” from microchip web page.
I’ll continue trying , and trying. I will tell you how everything is going on.