|
|
View previous topic :: View next topic |
Author |
Message |
shalia
Joined: 31 Mar 2013 Posts: 2
|
GM862 - PIC4550 |
Posted: Sun Mar 31, 2013 7:49 pm |
|
|
Hi,
First, I'm a beginner in electronic and I'm very sorry for my bad english...
I have a little problem to display the response of the GM862 on a LCD.
I'm using the Smart GM862 board and a studyboard with a PIC4550.
The communication is ok between my computer (using RS232) and the module : I send AT commands and the module answers correctly.
But when I try to connect my PIC and the module, I've strange symbols on my LCD.
So I think my code is wrong.
Somebody can take a look on it ?
Code: |
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
boolean FlagGM = 0;
char gm[5]={' ',' ',' ',' ',' '};
int i = 0;
#int_RDA
void RDA_isr(void)
{
gm[i]=getc();
FlagGM=1;
i++;
if(i==5)
i=0;
}
void main()
{
enable_interrupts(INT_RDA);
lcd_init();
delay_ms(100);
lcd_putc('\f');
printf("\n");
printf("\r");
printf("A");
printf("T");
printf("\n");
printf("\r");
for(;;){
lcd_gotoxy(1,1);
if(FlagGM)
{
printf(lcd_putc, "%c%c%c%c%c", gm[0],gm[1],gm[2],gm[3],gm[4]);
FlagGM=0;
}
}
}
|
Thank you very much !
Last edited by shalia on Mon Apr 01, 2013 4:02 am; edited 2 times in total |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sun Mar 31, 2013 9:37 pm |
|
|
Hi,
This topic has been covered many, many times. You really need to search the forum archives before asking your question!
BTW, is this a "real" hardware project or a Proteus simulation? I ask because as written your interrupt should not fire at all, as you have not enabled the interrupt properly!
If this is a real hardware project, tell us how you have the GM862 connected to the PIC.
Also, always post a complete, compilable program for us to test. As posted, yours is not complete!
John |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Apr 01, 2013 3:56 am |
|
|
As a comment:
Code: |
printf("\n");
printf("\r");
printf("A");
printf("T");
printf("\n");
printf("\r");
//why not use:
printf("\n\rAT\n\r");
|
Best Wishes |
|
|
shalia
Joined: 31 Mar 2013 Posts: 2
|
|
Posted: Mon Apr 01, 2013 9:53 am |
|
|
Ttelmah > after lot of tests, I put all this lines (first I tried your suggestion)... It seems to be more logical ! You are right. I put it back
ezflyr > I really have searched before asking but I didn't find anything :|
This is a real hardware project.
I don't mention the connections because I have tested the RS232<->GM862 connection and the RS232<->PIC connection, these work properly with the Hyperterminal of WinXP. So the connections are ok I think.
But when I connect the PIC<->GM862, that fails : I receive strange symbols...
Here is my code :
Code: |
#include "...\AT PIC GM862 test 2\main.h"
#include "...\AT PIC GM862 test 2\LCD420_18f4550.C"
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#byte PORTC = 0xf82
#byte PORTD = 0xf83 //PortD = LCD
#byte TRISC = 0xf94
#byte TRISD = 0xf95
#bit RD0 = 0xf83.0
boolean FlagGM = 0;
char gm[16]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
int i = 0 ;
#int_RDA
void RDA_isr(void)
{
gm[i]=getc();
FlagGM=1;
i++;
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_EXT);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
set_tris_d(0x00);
RD0 = 1;
lcd_init();
delay_ms(100);
lcd_putc('\f');
printf("AT\n\r");
for(;;){
lcd_gotoxy(1,1);
if(FlagGM)
{
delay_ms(1000);
printf(lcd_putc, "%c%c%c%c%c%c%c%c%c%c%c%c%c", gm[0],gm[1],gm[2],gm[3],gm[4],gm[5],gm[6],gm[7],gm[8],gm[9],gm[10],gm[11],gm[12]);
i=0;
FlagGM=0;
gm[0]=' ';
gm[1]=' ';
gm[2]=' ';
gm[3]=' ';
gm[4]=' ';
gm[5]=' ';
gm[6]=' ';
gm[7]=' ';
gm[8]=' ';
gm[9]=' ';
gm[10]=' ';
gm[11]=' ';
gm[12]=' ';
gm[13]=' ';
gm[14]=' ';
gm[15]=' ';
}
}
} |
I know that parts of command arrive to the GM862 because I blocked my SIM Card after trying to send 3 times a wrong pin code (when I tried AT+CPIN=1111)
=> 1111 is the right pin code but the card was blocked => I think the module "have understood" the AT+CPIN= but took a wrong pin code => why !?
I know my code is probably awful for a good programmer... I am beginner :|
So, do you think there is a big mistake in the code ?
Thanks |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Apr 02, 2013 7:50 am |
|
|
Hi,
For a 'Comm Test' program, your code is way too complicated! When you do that, there are too many other ways that the code can fail, so it's a poor test....
Here are some suggestions:
1. Dedicate a PIC pin to diagnostic serial communications. Connect this pin to your PC serial port thru a MAX232 device. Do this because an LCD is a poor diagnostic display, especially for a novice programmer!
2. For a simple test program, especially one that you will post here for help, keep all your code in one file. If you continue to use it, the exception is the LCD code.
3. Add 'Errors' to your #use rs232 declaration.
4. Get rid of all the #byte/#bit and TRIS stuff in your code.
5. Get rid of the array for this test. It adds unnecessary complication - you just want to prove you can communicate with the GM862 at this point!
6. Get rid of the interrupt for this test. Send 'AT' - printf("\rAT\r") - to the modem, and then go into a loop to read and display the GSM response to Hyperterminal. The modem should respond with <CR><LF>OK<CR><LF>. Use fgetc() to read incoming characters from the GSM modem, and then fputc() to send them out to Hyperterminal. Use 'Streams' to specify the appropriate PIC serial resource.
You should also post a link to your GSM module. Clearly, it's on a carrier board with a MAX232 type device, right? If so, You should tell us this! If so, your PIC must also have a MAX232 type device to connect to the GSM module board, right?
Once you are absolutely sure this is working, start adding back the complexity taken out for this test!
Also, are you sure that the correct baud rate is 4800 for the GM862? That does not sound like a typical default!
John |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|