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.

Serial Communication ATmega128 Codevision AVR

Status
Not open for further replies.

ahmadabad

Newbie level 4
Joined
Sep 17, 2009
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,354
DEARS:
I want to send this string (+CMTI 'SM' +CMGR) from computer to avr 128 with usart and after receiving this string (+CMTI 'SM' +CMGR) by avr I will call other function f1.you can see my code in follow. But I have a problem. When I send other string i.e. (+CLIP: "+952178259109"), program jump to the f1 function again .i will program jump to f1 function only we received this string (+CMTI 'SM' +CMGR) not other string i.e. (+CLIP: "+952178259109"), I am using codevision. May be help me .

tkn



// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15
#endasm


#define RXB8 1
#define TXB8 0
#define UPE 2
#define OVR 3
#define FE 4
#define UDRE 5
#define RXC 7

#define FRAMING_ERROR (1<<FE)
#define PARITY_ERROR (1<<UPE)
#define DATA_OVERRUN (1<<OVR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)

// USART0 Receiver buffer
#define RX_BUFFER_SIZE0 248
char rx_buffer0[RX_BUFFER_SIZE0];
unsigned char rx_wr_index0,rx_rd_index0,rx_counter0;
// This flag is set on USART0 Receiver buffer overflow
bit rx_buffer_overflow0;
///////////////////////////////////////////////////////////////////////////////////////////////
bit recievedsms=0;

//////////////////////////////////////////////////////////////////////////////////////////////
// USART0 Receiver interrupt service routine
#pragma savereg-
interrupt [USART0_RXC] void uart0_rx_isr(void)
{
char status,data;
#asm
push r26
push r27
push r30
push r31
in r26,sreg
push r26
#endasm
status=UCSR0A;
data=UDR0;
if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
{
/////////////////////////////////////////////////////////////////////////////////////

if(data=='+')
{
rx_buffer0[0]=data;
rx_wr_index0=1;

}
else if(rx_wr_index0==1 && data=='C')
{
rx_buffer0[rx_wr_index0]=data;
rx_wr_index0++;
}
else if(rx_wr_index0==2 && data=='M')
{
rx_buffer0[rx_wr_index0]=data;
rx_wr_index0++;
}
else if(rx_wr_index0==3 && data=='T')
{
rx_buffer0[rx_wr_index0]=data;
rx_wr_index0++;
}
else if(rx_wr_index0==4 && data=='I')
{
rx_buffer0[rx_wr_index0]=data;
rx_wr_index0++;

}
else if(rx_wr_index0==5)
{
recievedsms=1;

}


/////////////////////////////////////////////////////////////////////////////////////
rx_buffer0[rx_wr_index0]=data;
if (++rx_wr_index0 == RX_BUFFER_SIZE0) rx_wr_index0=0;
if (++rx_counter0 == RX_BUFFER_SIZE0)
{
rx_counter0=0;
rx_buffer_overflow0=1;
};
};
#asm
pop r26
out sreg,r26
pop r31
pop r30
pop r27
pop r26
#endasm
}



.
.
.
.
.

while (1)
{

if(recievedsms==1)f1();



}
;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top