Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

NEED help in sending SMS via through AVR studio 4 using ATMEGA32

Status
Not open for further replies.

harmonybunny0770

Newbie level 1
Joined
Sep 20, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Hi i am currently working on sending sms via through a microcontroller(ATMEGA32) i am using AVR studio 4 and i'm using the USART commands apparently i've done the initialization and everything but i do not know why the data is still not sending out (I do not know why the UDR register is always empty and if my program run in the for loop twice the UDRE register will be cleared) PLEASE HELP ME !


here is my code (in c programming)

Code:
#include <stdio.h>
//#include <iostream.h>
//#include <cstdlib>
#include <avr/io.h> 
//#include <stdlib.h>
//#include <string.h>

#define USART_BAUDRATE 9600

#define F_CPU 1843200

#define UBRR 23

#define BAUDRATE (F_CPU/(8*(UBRR+1))) //9600

int i;




//char *COMMAND;

int main ()
{


//Initialising--------------------------------------------------------------------------

/* Set frame format: 
URSEL= 1 Selects UCSRC instead of UBRRH
UMSEL=0 Asynchronous Operation
UPM0=0 and UPM1=0 Parity Bit Disabled
USBS=0 1stop bit
UCSZ0=1 and UCSZ1=1 8data bits*/

UCSRC = (1<<URSEL)|(0<<UMSEL)|(0<<UPM0)|(0<<UPM1)|(0<<USBS)|(1<<UCSZ0)|(1<<UCSZ1);



/* Set baud rate */

UCSRC=(0<<URSEL);//Select zero to select to write UBRRH register

 	UBRRH = (unsigned char)(BAUDRATE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
   	UBRRL = (unsigned char) BAUDRATE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register 

// Set speed 230.4 Kbps
UCSRA = (1<<U2X);
/* Enable receiver and transmitter */
UCSRB = (1<<TXEN); //(1<<RXEN)|

  

//FinishedInitialising---------------------------------------------------------------------

//Sending AT Commands-----------------------------------------------------------------------

for (i=0; i<=42; i++)
	{	
	
	
	char COMMAND[44] = "ATAT+CMGF=1AT+CMGS=+61425460247\rHI\r";

	UDR = COMMAND[i]; // Send out the byte value in the variable "ByteToSend"
	}

//	while (!(UCSRA & (1 << UDRE))) {}; // Do nothing until UDR is ready for more data to be written to it

//------------------------------------------------------------------------------------------
//return 0;
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top