- Joined
- Jul 4, 2009
- Messages
- 16,236
- Helped
- 5,140
- Reputation
- 10,309
- Reaction score
- 5,122
- Trophy points
- 1,393
- Location
- Aberdyfi, West Wales, UK
- Activity points
- 137,407
memset(buffer,0,sizeof(buffer));
__interrupt() void ISR(void)
{
if(RCIF)
{
buf = RCREG;
if(j < 61)
{
data[j] = buf;
j++;
data[j] = 0;
if(buf == '\n')
{
strcpy(res,data);
j=0;
}
}
__interrupt() void ISR(void)
{
if((RCIE) && (RCIF))
{
if(j < 61)
{
data[j++] = RCREG;
data[j] = 0;
}
else
{
RCIE = 0;
}
j = 0;
RCIE = 1;
}
//main code
while(1)
{
if(j >= 61)
{
if(strstr(data,"LOAD1 ON") != 0) //better to store all strings in
// ROM using const char data type as RAM is less.
{
RD0 = 1;
}
else if(strstr(data,"LOAD1 OFF") != 0)
{
RD0 = 0;
}
}
}
__interrupt() void ISR(void)
{
if((RCIE) && (RCIF))
{
if(j < 61)
{
data[j++] = RCREG;
data[j] = 0;
}
else
{
RCIE = 0;
}
RCIF = 0;
}
//main code
while(1)
{
if(j >= 61)
{
if(strstr(data,"LOAD1 ON") != 0) //better to store all strings in
// ROM using const char data type as RAM is less.
{
RD0 = 1;
}
else if(strstr(data,"LOAD1 OFF") != 0)
{
RD0 = 0;
}
j = 0;
RCIE = 1;
}
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 __interrupt() void ISR(void) { if((RCIE) && (RCIF)) { if(j < 61) { data[j++] = RCREG; data[j] = 0; } else { RCIE = 0; } RCIF = 0; } //main code while(1) { if(strstr(data,"+CMT: ") != 0) { if(strstr(data,"LOAD1 ON") != 0) { RD0 = 1; } else if(strstr(data,"LOAD1 OFF") != 0) { RD0 = 0; } if(strstr(data,"LOAD2 ON") != 0) { RD0 = 1; } else if(strstr(data,"LOAD2 OFF") != 0) { RD0 = 0; } j = 0; RCIE = 1; } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 __interrupt() void ISR(void) { if((RCIE) && (RCIF)) { data[j++] = RCREG; data[j] = 0; RCIF = 0; } //main code while(1) { if(strstr(data,"+CMT: ") != 0) { RCIE = 0; if(strstr(data,"LOAD1 ON") != 0) { RD0 = 1; } else if(strstr(data,"LOAD1 OFF") != 0) { RD0 = 0; } if(strstr(data,"LOAD2 ON") != 0) { RD0 = 1; } else if(strstr(data,"LOAD2 OFF") != 0) { RD0 = 0; } memset(data,0,sizeof(data)); j = 0; RCIE = 1; } }
Code C - [expand] 1 RCIE = 1;
There was a bug in my code. I have fixed it. Please test the attached .hex file
If it works fine then I will post my code.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?