پاسخ : مشکل با AVR و SIM 900
آقا شک نکن سخت افزارت گیر داره!! اصن یه وضی ...
آقا شک نکن سخت افزارت گیر داره!! اصن یه وضی ...
/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 2013/07/27
Author : NeVaDa
Company :
Comments:
Chip type : ATmega32
Program type : Application
AVR Core Clock frequency: 11.05920 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32.h>
#include <delay.h>
#asm
.equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
char Enter=13;
char double_quote=34;
char Ctrlz=26;
char TELL[12]="091***********";
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTD.5=1;
DDRD.5=0;
// 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: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 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;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=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: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x47;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
lcd_init(16);
while (1)
{
lcd_putsf(" W E L C O M E");
delay_ms(1000);
lcd_clear();
if(PIND.5==0)
{
while(PIND.5==0);
delay_ms(20);
printf("at+cmgs=%c%s%c%c",double_quote,TELL,double_quote,Enter);
while(getchar()!='k');
printf("MORTEZA ");
delay_ms(1000);
putchar(Ctrlz);
delay_ms(10);
putchar(Ctrlz);
delay_ms(10);
putchar(Ctrlz);
delay_ms(10);
}
lcd_putsf(" F I N I S H ");
delay_ms(1000);
lcd_clear();
}
}
/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 2013/07/30
Author : NeVaDa
Company :
Comments:
Chip type : ATmega32
Program type : Application
AVR Core Clock frequency: 11.059200 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32.h>
#include <stdio.h>
#include <delay.h>
#asm
.equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>
char Enter=13;
char double_quote=34;
char Ctrlz=26;
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTD=0x00;
DDRD=0x00;
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x26;
lcd_init(16);
while(1)
{
lcd_putsf(" Start ");
delay_ms(1000);
lcd_clear();
if(PIND.2==0)
{
printf("at%c",Enter);
delay_ms(500);
printf("AT+CMGF=1%c",Enter);
delay_ms(500);
printf("at+cmgs=%c091*********%c%c",double_quote,double_quote,Enter);
delay_ms(100);
printf("AVR TEST 1%c",Ctrlz);
delay_ms(100);
};
lcd_putsf(" E N D ");
delay_ms(1000);
lcd_clear();
};
}
oo:
oo:
oo:
oo:
oo:
:nice: :nice: :nice: :nice:
:nice: :nice: :nice: :nice:/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 2013/07/30
Author : NeVaDa
Company :
Comments:
Chip type : ATmega32
Program type : Application
AVR Core Clock frequency: 11.059200 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>
#include <delay.h>
// Standard Input/Output functions
#include <stdio.h>
#define enter 0x0d
#define ctrl_z 0x1a
char sms_text[20]="SALAM";
char Ctrlz='s';
// Declare your global variables here
flash char at_cmgs[]= {'A','T','+','C','M','G','S','=','"','+','9','8','9','1','*','*','*','*','*','*','*','*','"','\r'};
void wait_to_get(char ch)
{
while(ch != getchar());
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A 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
PORTA=0x00;
DDRA=0xFF;
// Port B 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
PORTB=0x00;
DDRB=0x00;
// Port C 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
PORTC=0x00;
DDRC=0x00;
// 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;
// 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: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 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;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=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: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x47;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// LCD module initialization
lcd_init(16);
// printf("%s%c",sms_text,Ctrlz);
lcd_putsf("Start");
delay_ms(1000);
lcd_clear();
while (1)
{
// Place your code here
putsf(at_cmgs);
wait_to_get('>');
printf("%s%c",sms_text,Ctrlz);
putchar(ctrl_z);
lcd_putsf("Massage Sent");
delay_ms(1000);
lcd_clear();
};//EXT.CRYSTAL=11.0592
}
دیدگاه