microcontroller fail to sms to gsm modem..(AT command code)

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
lazyhut
Posts: 7
Joined: 13 Feb 2011 03:21

microcontroller fail to sms to gsm modem..(AT command code)

#1 Post by lazyhut » 14 Feb 2011 02:01

gsm modem model: MOD 9001D RS232 GSM/GPRS
Microcontroller: PIC16F877A
software:MikroC

I am newbie in mikro C programming and AT command to send SMS in microcontroller.
I tried this Command code via hyperterminal it worked.
i have connect it with PIC16F877A via max232
My problem is:
when connect using microcontroller it won't send message to my phone and reply data from gsm modem.

Hypertiminal Command:

Code: Select all

AT+CMGF=1 [enter]
O.K           [received]
AT+CMGS="xxxxxx" [enter]
>              [received]
Testing123 ctr+Z [sent]

Code: Select all

[b]Programming:[/b]
void ADC_value_to_PC(){

uart1_write_text("at+cmgf=1");
UART1_Write(13);
UART1_Write(10);
delay_ms(5000);

UART1_Write_text("AT+CMGS=\"xxxxxxx\"");
UART1_Write(13);
UART1_Write(10);
delay_ms(5000);

UART1_Write_Text("Testing123");
UART1_Write(0x1A);
}

void main() {
TRISA=0x01;                    //I/O declarations
TRISB=0x00;
TRISC=0x00;
TRISD=0x00;
TRISE=0x00;

PORTA=0xFE;                    //Ports declarations
PORTB=0x00;
PORTC=0x00;
PORTD=0xff;
PORTE=0x07;

uart1_init(9600);
delay_ms(5000);
ADC_value_to_PC();            //Call function
}
below is my connection of max232 via mircocontroller
uart1.JPG
uart1.JPG (65.79 KiB) Viewed 4401 times

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: microcontroller fail to sms to gsm modem..(AT command co

#2 Post by slavisa.zlatanovic » 14 Feb 2011 12:09

Hi!

Please, follow the link below:
http://www.mikroe.com/eng/downloads/get ... s_v100.zip
There you can find the Relay example. It's about activating relays via SMS.
I'm sure that this example can help you get started with your project.

Also, consult the PICPLC16 v6 development board schematic:
http://www.mikroe.com/eng/downloads/get ... c_v101.pdf
It will help you with the GSM module connections to the MCU, serial port, etc...
Best regards
Slavisa

lazyhut
Posts: 7
Joined: 13 Feb 2011 03:21

Re: microcontroller fail to sms to gsm modem..(AT command co

#3 Post by lazyhut » 14 Feb 2011 18:00

slavisa.zlatanovic wrote:Hi!

Please, follow the link below:
http://www.mikroe.com/eng/downloads/get ... s_v100.zip
There you can find the Relay example. It's about activating relays via SMS.
I'm sure that this example can help you get started with your project.

Also, consult the PICPLC16 v6 development board schematic:
http://www.mikroe.com/eng/downloads/get ... c_v101.pdf
It will help you with the GSM module connections to the MCU, serial port, etc...
i did read the example..
but i still cant understand it the programming..
can u list some code for me ?

lazyhut
Posts: 7
Joined: 13 Feb 2011 03:21

Re: microcontroller fail to sms to gsm modem..(AT command co

#4 Post by lazyhut » 15 Feb 2011 04:32

i got an errors of Undeclared identifier 'LATA' in expression 'LATB' 'LATC' and so on
what is 'LATA' actually ? how to declared it ?

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: microcontroller fail to sms to gsm modem..(AT command co

#5 Post by slavisa.zlatanovic » 16 Feb 2011 10:32

Hi!
i got an errors of Undeclared identifier 'LATA' in expression 'LATB' 'LATC' and so on
what is 'LATA' actually ? how to declared it ?
LATx are MCU registrers declared in the MCU definition file located in the Defs folder (look into your compiler installation folder).
Also, you obviously changed the MCU in the Project settings and tried to compile the original project for some other chip (different from the one the example was originally built for).
You choosed the MCU which doesn't have the LATA, LATB and LATC registers.
Instead, you could use i.e. PORTA, PORTB and PORTC regs (if declared in the MCU definition file).
Best regards
Slavisa

Post Reply

Return to “mikroC PRO for PIC General”