View previous topic :: View next topic |
Author |
Message |
tracy83
Joined: 28 Feb 2006 Posts: 4
|
Need help on communication between GSM-PIC |
Posted: Wed Mar 01, 2006 2:20 am |
|
|
Hi there,I am a newbie in doing this project.I need some help on this project.
I want my PIC to send a voice call command to my GSM without using the Hyperterminal.Would it be possible?Below are my very 1st testing program but it seem like not working at all.Can somebody help to comment on it?I really appreciate ur help coz i'm really running out of time now.
#include <16F876.h> // Defines chip
#use delay(clock=20000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=38400, XMIT=Pin_c6, rcv=pin_c7, parity=n, bits=8)
#byte portc=7
const int CR=0x0d;
void main()
{
set_tris_c_(0x80)
printf("AT");
putc(CR);
delay_ms(10000);
printf("ATD0126196149;");
putc(CR);
}
Best Regards
tracy |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Wed Mar 01, 2006 7:25 am |
|
|
Hello
Your GSM works at 38400kbs?
To dial a number you only need to do
printf("atd123456789\r");
Jaime |
|
|
tracy83
Joined: 28 Feb 2006 Posts: 4
|
|
Posted: Wed Mar 01, 2006 9:02 am |
|
|
hi jaime...
ya...my GSM work with 38400kbps.I'll try with ur suggestion and let you know how is it...thanks alot |
|
|
tracy83
Joined: 28 Feb 2006 Posts: 4
|
urgent help |
Posted: Sun Mar 05, 2006 1:45 pm |
|
|
hi there...
#include <16F876.h> // Defines chip
#use delay(clock=20000000) // Defines delay_clock
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=38400, XMIT=Pin_c6, rcv=pin_c7, parity=n, bits=8)
#byte portc=7
void main()
{
set_tris_c(0x80);
printf("AT#SHDN\r");
}
When i sent the above program to my hypertterminal,it only display AT#SHD.can somebody help? |
|
|
SteveL Guest
|
|
Posted: Sun Mar 05, 2006 3:17 pm |
|
|
It's because you're using the hardware UART which buffers 2 or 3 bytes (can't remember exactly) so your code sends the characters to the PIC UART buffer for transmission as soon as the current character has finished. But CCS insert a hidden SLEEP instruction after the closing brace of main(). So you send the characters to the PIC buffer, then the PIC hits the sleep instruction & turns off the internal clocks so the characters in the buffer can't be sent.
The simplest thing for testing is to add a delay after the printf of at least 3 bytes (3*8 data bits +1 start bit +1 stop bit) at 38400 baud
or (3*10*(1/38400)) = 781uS so try delay_ms(1).
However this is not good programming and you should avoid letting the code fall out of main() by making an infinite loop. |
|
|
|