- This topic has 2 replies, 2 voices, and was last updated 11 years, 6 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › problem with sending sms from atmega32
hi…, we typed this code for sending sms from atmega32 using sim300.but its not responding.. can you please help us as soon as possible #include <avr/io.h>
#include <stdio.h>
#define F_CPU 16000000ul
#include <util/delay.h>
?
#define BAUD 9600
#define MYUBRR F_CPU/16/BAUD-1
?
void usart_init(uint16_t ubrr);
void usart_putchar(char data);
void usart_pstr (char *s);
void usart_init( uint16_t ubrr) {
//PORTD=0x00;
//DDRD=0x02;
// Set baud rate
UBRRL = (uint8_t)ubrr;
UBRRH = (uint8_t)(ubrr>>;
// Enable receiver and transmitter
UCSRB = (1<<RXEN)|(1<<TXEN);
// Set frame format: 8data, 1stop bit
UCSRC = (1<<URSEL)|(3<<UCSZ0);
}
unsigned int usart_getch()
{
while (!(UCSRA & (1 << RXC)) ); // Do nothing until data has been received and is ready to be read from UDR
_delay_ms(1);
return(UDR); // return the byte
}
?
void usart_putchar(char data) {
// Wait for empty transmit buffer
while ( !(UCSRA & (_BV(UDRE))) );
// Start transmission
UDR = data;
}
void usart_pstr(char *s)
{
// loop through entire string
while (*s) {
usart_putchar(*s);
s++;
}
}
int main()
{
//PORTD=0x00;
//DDRD=0x02;
usart_init(MYUBRR);
//usart_pstr(“AT+CMGD=1;rn”);
usart_pstr(“ATArn”);
usart_pstr(“AT+CMGF=1rn”);
_delay_ms(2000);
usart_pstr(“AT+CMGS=”+919141147771″rn”);
_delay_ms(2000);
usart_pstr(“hellor”);
usart_pstr(“0x1Arn”);
return 0;
}
8 views not even one reply:( pls guys im in final year BE and need to continue my project… Pls do help me soon pls
Hi Rama,
Have you tried to send the same command using hyperterminal? How was the response?
If you did, then connect your microcontroller to the PC hyperterminal and then run the code. You should get the same commands there. If you don’t get the same commands, then only you have to worry about the code. Otherwise it might be just a connection mistake.
Try and update the result.