gsm modem and stk500

Thread Starter

agnostos

Joined May 17, 2008
2
hello i have to make a project until this Monday and i have a big problem
i can send at commands to gsm modem but i can't get the answers and i don't know why.
the code is
Code:
/*****************************************************
This program was produced by the
CodeWizardAVR V1.25.9 Professional
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date : 16/5/2008
Author : ditoskas
Company : ditoskas
Comments:


Chip type : ATmega8515L
Program type : Application
Clock frequency : 4,000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 128
*****************************************************/

#include <mega8515.h>

//TA CR KAI LF XRISIMOPOIOUNTAI GIA TIN APOSTOLI TOY ENTER.
#define CR 0x0D
#define LF 0x0A

//DEKAEKSADIKI TIMI TOY CTRL-Z EINAI I 0x1A.
#define CTRLZ 0x1A
#include <delay.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
//char msg[127];
char myData[127];
void GetData(void)
{
int i;
PORTB.1 = 1;
delay_ms(100);
PORTB.1 = 0;
for (i = 0;i<10;i++)
{
PORTB.1 = 1;
myData = getchar();
// delay_ms(100);
PORTB.1 = 0;
// if (myData=='\0')
// break;
}
}
void SendSms(void)
{
printf("at+cmgs=6938699188");
putchar( CR ); //CR
putchar( LF ); //LF
delay_ms(100);
printf("%s","TEST");
putchar(CTRLZ);
// putchar( LF ); //LF
};

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=1 State0=T
PORTC=0x02;
DDRC=0x02;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// Port E initialization
// Func2=In Func1=In Func0=In
// State2=T State1=T State0=T
PORTE=0x00;
DDRE=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
EMCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 115200
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=4000000/16/115200-1;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
PORTB.0 = 0;
PORTB.1 = 0;
//printf("ATE0\r\n");
while(1)
{
printf("AT \r\n");

PORTB.0 = 1;
scanf("%s", myData);
//GetData();
printf("at+cmgs=6938699188\r\n");

printf("%s",myData);
putchar(CTRLZ);
delay_ms(1000);
// if (myData[0] == 'O')
PORTB.0 = 0;
break;
}
}



when i use the scanf command i get the same information that i send (the AT command) if use the GetData() the program crash out. why??? what must i change to read a message from gsm???
(the connection between gsm and stk is why null modem cable (2 females) and i connect the 2,3,5 pins from cable to 3,2,5 on avr the same connection is on modem)

please help me because time pressure me and i don't know what to do...

i hope to your answer...
 

hgmjr

Joined Jan 28, 2005
9,027
Rich (BB code):
/***************************************************** 
This program was produced by the 
CodeWizardAVR V1.25.9 Professional 
Automatic Program Generator 
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. 
http://www.hpinfotech.com 
 
Project : 
Version : 
Date : 16/5/2008 
Author : ditoskas 
Company : ditoskas 
Comments: 
 
 
Chip type : ATmega8515L 
Program type : Application 
Clock frequency : 4,000000 MHz 
Memory model : Small 
External SRAM size : 0 
Data Stack size : 128 
*****************************************************/ 
 
#include <mega8515.h> 
 
//TA CR KAI LF XRISIMOPOIOUNTAI GIA TIN APOSTOLI TOY ENTER. 
#define CR 0x0D 
#define LF 0x0A 
 
//DEKAEKSADIKI TIMI TOY CTRL-Z EINAI I 0x1A. 
#define CTRLZ 0x1A 
#include <delay.h> 
// Standard Input/Output functions 
#include <stdio.h> 
// Declare your global variables here 
//char msg[127]; 
char myData[127]; 
void GetData(void) 
{ 
   int i; 
   PORTB.1 = 1; 
   delay_ms(100); 
   PORTB.1 = 0; 
   for (i = 0;i<10;i++) 
   { 
      PORTB.1 = 1; 
      myData = getchar(); 
      // delay_ms(100); 
      PORTB.1 = 0; 
      // if (myData=='\0') 
      // break; 
   } 
} 
 
 
void SendSms(void) 
{ 
   printf("at+cmgs=6938699188");  
   putchar( CR ); //CR 
   putchar( LF ); //LF  
   delay_ms(100); 
   printf("%s","TEST"); 
   putchar(CTRLZ); 
   // putchar( LF ); //LF 
   }; 
 
void main(void) 
{ 
   // Declare your local variables here 
 
   // Input/Output Ports initialization   
   // Port A initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T   State1=T State0=T 
   PORTA=0x00; 
   DDRA=0x00; 
 
   // Port B initialization 
   // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
   // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
   PORTB=0x00; 
   DDRB=0xFF; 
 
   // Port C initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T State1=1 State0=T 
   PORTC=0x02; 
   DDRC=0x02; 
 
   // Port D initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
   PORTD=0x00; 
   DDRD=0x00; 
 
   // Port E initialization 
   // Func2=In Func1=In Func0=In 
   // State2=T State1=T State0=T 
   PORTE=0x00; 
   DDRE=0x00; 
 
   // Timer/Counter 0 initialization 
   // Clock source: System Clock 
   // Clock value: Timer 0 Stopped 
   // Mode: Normal top=FFh 
   // OC0 output: Disconnected 
   TCCR0=0x00; 
   TCNT0=0x00; 
   OCR0=0x00; 
 
   // Timer/Counter 1 initialization 
   // Clock source: System Clock 
   // Clock value: Timer 1 Stopped 
   // Mode: Normal top=FFFFh 
   // OC1A output: Discon. 
   // OC1B output: Discon. 
   // Noise Canceler: Off 
   // Input Capture on Falling Edge 
   // Timer 1 Overflow Interrupt: Off 
   // Input Capture Interrupt: Off 
   // Compare A Match Interrupt: Off 
   // Compare B Match Interrupt: Off 
   TCCR1A=0x00; 
   TCCR1B=0x00; 
   TCNT1H=0x00; 
   TCNT1L=0x00; 
   ICR1H=0x00; 
   ICR1L=0x00; 
   OCR1AH=0x00; 
   OCR1AL=0x00; 
   OCR1BH=0x00; 
   OCR1BL=0x00; 
 
   // External Interrupt(s) initialization 
   // INT0: Off 
   // INT1: Off 
   // INT2: Off 
   MCUCR=0x00; 
   EMCUCR=0x00; 
 
   // Timer(s)/Counter(s) Interrupt(s) initialization 
   TIMSK=0x00; 
 
   // USART initialization 
   // Communication Parameters: 8 Data, 1 Stop, No Parity 
   // USART Receiver: On 
   // USART Transmitter: On 
   // USART Mode: Asynchronous 
   // USART Baud Rate: 115200 
   UCSRA=0x00; 
   UCSRB=0x18; 
   UCSRC=0x86; 
   UBRRH=0x00; 
   UBRRL=4000000/16/115200-1; 
 
   // Analog Comparator initialization 
   // Analog Comparator: Off 
   // Analog Comparator Input Capture by Timer/Counter 1: Off 
   ACSR=0x80; 
   PORTB.0 = 0; 
   PORTB.1 = 0; 
   //printf("ATE0\r\n"); 
   while(1) 
   { 
      printf("AT \r\n"); 
 
      PORTB.0 = 1; 
      scanf("%s", myData); 
      //GetData(); 
      printf("at+cmgs=6938699188\r\n"); 
 
      printf("%s",myData); 
      putchar(CTRLZ); 
      delay_ms(1000); 
      // if (myData[0] == 'O') 
      PORTB.0 = 0; 
      break; 
   } 
} 
 



Code formatting to enhance readability.

hgmjr
 

Thread Starter

agnostos

Joined May 17, 2008
2
i am sorry but i don't understand what you mean where is the error????
Rich (BB code):
/***************************************************** 
This program was produced by the 
CodeWizardAVR V1.25.9 Professional 
Automatic Program Generator 
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. 
http://www.hpinfotech.com 
 
Project : 
Version : 
Date : 16/5/2008 
Author : ditoskas 
Company : ditoskas 
Comments: 
 
 
Chip type : ATmega8515L 
Program type : Application 
Clock frequency : 4,000000 MHz 
Memory model : Small 
External SRAM size : 0 
Data Stack size : 128 
*****************************************************/ 
 
#include <mega8515.h> 
 
//TA CR KAI LF XRISIMOPOIOUNTAI GIA TIN APOSTOLI TOY ENTER. 
#define CR 0x0D 
#define LF 0x0A 
 
//DEKAEKSADIKI TIMI TOY CTRL-Z EINAI I 0x1A. 
#define CTRLZ 0x1A 
#include <delay.h> 
// Standard Input/Output functions 
#include <stdio.h> 
// Declare your global variables here 
//char msg[127]; 
char myData[127]; 
void GetData(void) 
{ 
   int i; 
   PORTB.1 = 1; 
   delay_ms(100); 
   PORTB.1 = 0; 
   for (i = 0;i<10;i++) 
   { 
      PORTB.1 = 1; 
      myData = getchar(); 
      // delay_ms(100); 
      PORTB.1 = 0; 
      // if (myData=='\0') 
      // break; 
   } 
} 
 
 
void SendSms(void) 
{ 
   printf("at+cmgs=6938699188");  
   putchar( CR ); //CR 
   putchar( LF ); //LF  
   delay_ms(100); 
   printf("%s","TEST"); 
   putchar(CTRLZ); 
   // putchar( LF ); //LF 
   }; 
 
void main(void) 
{ 
   // Declare your local variables here 
 
   // Input/Output Ports initialization   
   // Port A initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T   State1=T State0=T 
   PORTA=0x00; 
   DDRA=0x00; 
 
   // Port B initialization 
   // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
   // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
   PORTB=0x00; 
   DDRB=0xFF; 
 
   // Port C initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T State1=1 State0=T 
   PORTC=0x02; 
   DDRC=0x02; 
 
   // Port D initialization 
   // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
   // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
   PORTD=0x00; 
   DDRD=0x00; 
 
   // Port E initialization 
   // Func2=In Func1=In Func0=In 
   // State2=T State1=T State0=T 
   PORTE=0x00; 
   DDRE=0x00; 
 
   // Timer/Counter 0 initialization 
   // Clock source: System Clock 
   // Clock value: Timer 0 Stopped 
   // Mode: Normal top=FFh 
   // OC0 output: Disconnected 
   TCCR0=0x00; 
   TCNT0=0x00; 
   OCR0=0x00; 
 
   // Timer/Counter 1 initialization 
   // Clock source: System Clock 
   // Clock value: Timer 1 Stopped 
   // Mode: Normal top=FFFFh 
   // OC1A output: Discon. 
   // OC1B output: Discon. 
   // Noise Canceler: Off 
   // Input Capture on Falling Edge 
   // Timer 1 Overflow Interrupt: Off 
   // Input Capture Interrupt: Off 
   // Compare A Match Interrupt: Off 
   // Compare B Match Interrupt: Off 
   TCCR1A=0x00; 
   TCCR1B=0x00; 
   TCNT1H=0x00; 
   TCNT1L=0x00; 
   ICR1H=0x00; 
   ICR1L=0x00; 
   OCR1AH=0x00; 
   OCR1AL=0x00; 
   OCR1BH=0x00; 
   OCR1BL=0x00; 
 
   // External Interrupt(s) initialization 
   // INT0: Off 
   // INT1: Off 
   // INT2: Off 
   MCUCR=0x00; 
   EMCUCR=0x00; 
 
   // Timer(s)/Counter(s) Interrupt(s) initialization 
   TIMSK=0x00; 
 
   // USART initialization 
   // Communication Parameters: 8 Data, 1 Stop, No Parity 
   // USART Receiver: On 
   // USART Transmitter: On 
   // USART Mode: Asynchronous 
   // USART Baud Rate: 115200 
   UCSRA=0x00; 
   UCSRB=0x18; 
   UCSRC=0x86; 
   UBRRH=0x00; 
   UBRRL=4000000/16/115200-1; 
 
   // Analog Comparator initialization 
   // Analog Comparator: Off 
   // Analog Comparator Input Capture by Timer/Counter 1: Off 
   ACSR=0x80; 
   PORTB.0 = 0; 
   PORTB.1 = 0; 
   //printf("ATE0\r\n"); 
   while(1) 
   { 
      printf("AT \r\n"); 
 
      PORTB.0 = 1; 
      scanf("%s", myData); 
      //GetData(); 
      printf("at+cmgs=6938699188\r\n"); 
 
      printf("%s",myData); 
      putchar(CTRLZ); 
      delay_ms(1000); 
      // if (myData[0] == 'O') 
      PORTB.0 = 0; 
      break; 
   } 
} 
 

Code formatting to enhance readability.

hgmjr
 
Top