kushal1211
Newbie level 4
I have the following code. I am trying to make port C high when i receive an SMS with "ON1" on GSM SIM900A.
But i am facing problems with interrupts it is not working. Following is the attached code. Help will be appreciated. I am using mikroC pro
But i am facing problems with interrupts it is not working. Following is the attached code. Help will be appreciated. I am using mikroC pro
Code:
#include <built_in.h>
unsigned char rx1[95],Rxdata;
unsigned int i=0,j;
void UartRxInterrupt() iv IVT_ADDR_USART__RXC
{
RxData = UART1_Read();
if(Rxdata=='S')
{
SREG|=(1<<7);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('R');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(50);
for(i=0;i<95;i++)
{
while (UART1_Data_Ready() != 1);
Rxdata = UART1_Read();
rx1[i] = Rxdata;
}
for(i=60;i<95;i++)
{
if(rx1[i]=='O' && rx1[i+1]=='N')
{
if(rx1[i+2]=='1')
{
PORTC = 0xFF;
}
if(rx1[i+2]=='2')
{
PORTC = 0x00;
}
if(rx1[i+2]=='3')
{
PORTC = 0x0f;
}
if(rx1[i+2]=='4')
{
PORTC = 0xf0;
}
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('D');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(100);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('D');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(100);
SREG|=(1<<7);
}
}
}
}
void main()
{
DDRC = 0xFF;
PORTC = 0x00;
UART1_Init(9600); // Initialize UART module at 9600 bps
UCSRB |= (1<<RXCIE);
SREG|=(1<<7); //Enable Global Interrupt
Delay_ms(100);
UART1_Write('A');
UART1_Write('T');
UART1_Write(13);
Delay_ms(200);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('F');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(200);
UART1_Write('A');
UART1_Write('T');
UART1_Write('e');
UART1_Write('0');
UART1_Write(13);
Delay_ms(200);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('N');
UART1_Write('M');
UART1_Write('I');
UART1_Write('=');
UART1_Write('1');
UART1_Write(',');
UART1_Write('1');
UART1_Write(',');
UART1_Write('0');
UART1_Write(',');
UART1_Write('0');
UART1_Write(',');
UART1_Write('0');
UART1_Write(13);
Delay_ms(50);
UART1_Write('A');
UART1_Write('T');
UART1_Write('&');
UART1_Write('W');
UART1_Write(13);
Delay_ms(50);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('D');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(200);
UART1_Write('A');
UART1_Write('T');
UART1_Write('+');
UART1_Write('C');
UART1_Write('M');
UART1_Write('G');
UART1_Write('D');
UART1_Write('=');
UART1_Write('1');
UART1_Write(13);
Delay_ms(200);
}