Sorry betwixt. I could not able to reply for more than a week. Because, I was not in a position (due to personal problem) to use internet for this period. I regret for that. Now I came back to work.
I think the problem in my code structure as you told in your earlier reply. So, I have changed my code as you suggested as follows. In order to understand my problem, I have posted the large code. Excuse for that:
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| #pragma code high_vector_section=0x8 //high interrupt vector
void high_vector (void)
{
if (INTCONbits.RBIF){
KeyPad_Interrupt();
// return;
}
else{
button();
// return;
}
}
#pragma code rx_interrupt = 0x18 //low interrupt vector
void rx_int (void)
{
rx_handler();
// return;
}
#pragma code
#pragma interrupt button
void button (void)
{
if (LED == 1){
LED = 0;
ALARM = 1;
strcpypgm2ram(WhatToDo, (const far rom char*)"SendSMS_SwitchOnOff");
strcmppgm2ram(identity, (const far rom char*)"SendSMS_Interrupt");
while (BusyUSART());
putrsUSART((const far rom char*)"AT+CMGS=");
putcUSART(0x22);
putsUSART(strBuff_IncomingPhNum);
putcUSART(0x22);
while (BusyUSART());
putcUSART(0x0D);
}
/* clear the interrupt flag */
INTCONbits.INT0IF = 0;
}
#pragma interrupt KeyPad_Interrupt
void KeyPad_Interrupt(void){
showPressedKey();
}
void showPressedKey(void){
.
.
.
.
}
#pragma interruptlow rx_handler // changed the interrupt to interruptlow
void rx_handler (void)
{
unsigned char input;
PIR1bits.RCIF = 0; // clear interrupt flag
input = ReadUSART();
switch(input){
case '\x0A':
.
case '': showGSM_DATA(gsmOutput_c[]);
.
default:
}
}
void showGSM_DATA(char gsmOutput_s[]){
.
.
.
.
.
} |
The above code works fine for Button, Keypad interrupt.
But for the rx_handler interrupt there is a error I encountered. For example the following code works fine.
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
45
46
47
48
| //Processing and Validating GSM_MODEM_OR_MODULE OUTPUT
void showGSM_DATA(char gsmOutput_s[]){
if (strcmppgm2ram(gsmOutput_s, (const far rom char*)"OK") == 0){
OK = TRUE;
}
if (strcmppgm2ram(gsmOutput_s, (const far rom char*)"ERROR") == 0){
OK = FALSE;
return;
}
// READING PHONE BOOK AND COPY ALL STORED PHONE NUMBERS INTO
// ARRAY FOR FUTURE REFERENCE AND FOR VALIDATION
if(strcmp(NextGSMCmd, Read_PhBk) == 0){
*NextGSMCmd = 0;
WriteCmdXLCD(CLR_LCD);
while(BusyXLCD());
WriteCmdXLCD(HOME_LCD);
while(BusyXLCD());
if (OK == TRUE){
OK = FALSE;
strcpypgm2ram(NextGSMCmd, (const far rom char*) "store_PhBk_Into_Array");
*gsmOutput_s = 0;
count_CPBR = 0;
while (BusyUSART());
putrsUSART((const far rom char *)"AT+CPBR=1");
while (BusyUSART());
putcUSART(0x0A);
putcUSART(0x0D);
}
else{
putrsXLCD("BAUD SETTING ERROR");
}
return;
}
}
if (strcmp(strBuff, PH_BK_CPBR) == 0){
*strBuff = 0;
if (strcmppgm2ram(NextGSMCmd, (const far rom char*) "store_PhBk_Into_Array") == 0){
strcpypgm2ram(NextGSMCmd, (const far rom char*) "PhBk_Stored"); |
HERE THE PROBLEM ARAISES: i.e. If we comment the following code entire thing works fine.
Code C - [expand] |
1
2
3
4
5
6
7
| /*
WriteCmdXLCD(CLR_LCD);
while(BusyXLCD());
WriteCmdXLCD(HOME_LCD);
while(BusyXLCD());
putrsXLCD("gsmOutput_s");
*/ |
But, If I uncomment, the data displayed correctly and hangs.
Code C - [expand] |
1
2
3
4
5
| WriteCmdXLCD(CLR_LCD);
while(BusyXLCD());
WriteCmdXLCD(HOME_LCD);
while(BusyXLCD());
putrsXLCD("gsmOutput_s"); |
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
| }
return;
}
if (strcmppgm2ram(NextGSMCmd, (const far rom char*) "PhBk_Stored") == 0){
*NextGSMCmd = 0;
*gsmOutput_s = 0;
count_CPBR = 0;
WriteCmdXLCD(CLR_LCD);
while(BusyXLCD());
WriteCmdXLCD(HOME_LCD);
while(BusyXLCD());
if (OK == TRUE){
OK = FALSE;
putrsXLCD("PH BK READ - OK");
}
else{
putrsXLCD("PH BOOK ERROR");
}
return;
} |
Any help to locate the issue. I strongly believe that the error could be related to interrupt as you told. But, I do not know how to change the code. Pl go thro' and pl guide me.
Advance thanks.