My application is using two interrupts at the same time: serial interrupt and external interrupt (INT0). I seems like they are bugging one another, and sometimes it causes the program to hang. Could some experts in this forum take a look at my code below. Thanks in advance.
void main() IT0 = 1; // Configure interrupt 0 EX0 = 1; //enable INT0 serial_init(); EA = 1; //enable global interrupt while(1) //endless loop --waiting { } /////Setup serial port////////// void serial_init (void) { SCON = 0x50; mode 1: 8-bit UART, TMOD |= 0x20; // timer 1 mode 2: TH1 = 0xf3; // 2400 baud TR1 = 1; // timer1 run ES = 1; // enable serial int PS = 0; //serial int to low-priority } ////////// serial service routine ///// void serial (void) interrupt 4 using 2 { if (RI) { array[index] = SBUF; //Get char RI = 0; //clear flag index++; } if (TI) { TI = 0; SBUF = out; // Transmit char } //////INTO interrupt service routine//////// unsigned char ex0_isr_counter = 0; void ex0_isr (void) interrupt 0 { perform_task1(); //call a function }