Madhushani
Newbie level 5
Hello everyone,
Please help me!
I am new to this forum and this is my first post
I am using Sim900d for sending SMS with AVR microcontroller atmega 32.
I program this code that writes with CodeVision AVR C compiler, but this doesn't work.
I don't know where is wrong, can u help me?
Thanks all.
Please help me!
I am new to this forum and this is my first post
I am using Sim900d for sending SMS with AVR microcontroller atmega 32.
I program this code that writes with CodeVision AVR C compiler, but this doesn't work.
I don't know where is wrong, can u help me?
Thanks all.
C:
/*******************************************************
This program was created by the
CodeWizardAVR V3.12 Advanced
Chip type : ATmega32
Program type : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*******************************************************/
#include <mega32.h>
#include <delay.h>
#include <alcd.h>
#include <stdio.h>
#define ADC_VREF_TYPE ((0<<REFS1) | (0<<REFS0) | (0<<ADLAR))
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UBRRH=0x00;
UBRRL=0x67;
// ADC initialization
// ADC Clock frequency: 125.000 kHz
// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: ADC Stopped
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 3
// D5 - PORTC Bit 4
// D6 - PORTC Bit 5
// D7 - PORTC Bit 6
// Characters/line: 16
lcd_init(16);
while (1)
{
if (PIND.2 == 1)
delay_ms(100);
if (PIND.2 == 1){
PORTB.0 = 1;
lcd_gotoxy(0,0);
lcd_puts("Operation status");
lcd_puts("phase 1 fault ");
printf("\r\n");
delay_ms(100);
printf("AT+CMGF=1\r\n");
delay_ms(100);
printf("AT+CMGS=\"Phone number\"\r\n");
delay_ms(100);
printf ("Message Body");
delay_ms(100);
putchar(0x1a);
delay_ms(100);
}
if (PIND.2 == 0)
delay_ms(100);
if (PIND.2 == 0){
PORTB.0 = 0;
lcd_gotoxy(0,0);
lcd_puts("Operation status");
lcd_puts("Normal Operation");
}
}}