View previous topic :: View next topic |
Author |
Message |
falonsos
Joined: 01 May 2010 Posts: 5
|
Cellphone PIC interaction |
Posted: Wed May 19, 2010 2:54 pm |
|
|
Hello!
I'm making a project to send and receive SMS using a Siemens C66 and a PIC 16F877a.
I can send SMS (using PDU mode) but I haven't tried to receive SMS yet. First I tried to send "AT" to get the response "OK" but all I get from the cellphone is "at", no matter what I send him (I tried with several commands).
The code I'm using is:
Code: |
#include <16F877A.h>
//#device adc=8
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#FUSES NOWDT //No Watch Dog Timer
#FUSES RC //Resistor/Capacitor Osc with CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#include <math.h>
#include <string.h>
#include <kbd44.c>
#include <lcd.c>
void main()
{
lcd_init();
while(TRUE){
delay_ms(100);
printf("AT\n\r");
while(TRUE){//i read all the time to get whats going on
if(kbhit()){
reci = getc();
printf(lcd_putc,"%c",reci);//print on LCD to see whats going on
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 19, 2010 5:20 pm |
|
|
Quote: | #include <16F877A.h>
//#device adc=8
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#FUSES NOWDT //No Watch Dog Timer
#FUSES RC |
The RC fuse is wrong for 20 MHz operation. You should use HS.
Also, you have a big delay_ms() statement in your code, so add
the 'ERRORS' parameter to clear any UART Rx overrun errors that
may occur while inside the delay. Example:
Quote: | #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,bits=8, ERRORS) |
|
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Thu May 20, 2010 9:39 am |
|
|
Not all phones support _all_ AT commands. Check your phone's manual or online forums to see if you can read SMSes from your phone. On my Nokia 3500c, I can send SMSes using AT commands, but I can't read them :-| (don't know why they'd not implement something like that, though).
Rohit |
|
|
falonsos
Joined: 01 May 2010 Posts: 5
|
|
Posted: Thu May 20, 2010 1:50 pm |
|
|
Thanks a lot PCM programmer, I implement what you just wrote but I still don't have any results, I still receive an "echo" from the cellphone. (what I send through the PIC is the same I'm receiving. But only when I put AT+XXX. If I don't put the AT before the message I don't get a response).
I have just check that the cellphone able to read SMS with AT commands, but what I think is still strange is that I receive an echo (exactly what I send).
Thanks in advance. |
|
|
sjb
Joined: 13 Apr 2010 Posts: 34 Location: UK
|
Re: Cellphone PIC interaction |
Posted: Fri May 21, 2010 12:39 am |
|
|
falonsos wrote: | The code I'm using is:
|
Are you sure about that line end sequence. That now even DOS(which would be \r\n.
According to wikipedia the HAYES command set needs just a CR ('\r') to complete the command. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri May 21, 2010 6:50 am |
|
|
hi,
yo could try using a SE T290A ... sends and recieves txt msgs......its what i use with much success
i posted code to recieve text sms on the "code Library" part of this forum
under "recieving TXT messages"
you can look at some of my routines....for proper comands.....
i think "sjb" might have a point in the end line sequence....
i send my returns as hex chars.... and NO Newline.......
take a look....
http://www.ccsinfo.com/forum/viewtopic.php?t=42527
Gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
falonsos
Joined: 01 May 2010 Posts: 5
|
|
Posted: Sun May 23, 2010 11:51 am |
|
|
I solved the problem.
It was that i get each char and then print it on the LCD screen wasting time on that, so i missed a lot of chars coming on Rx while printing.
Thanks a lot for your help!
Also, i hope this topic would help other people to. |
|
|
|