void UART0_ISR(void) interrupt 4 { if (RI == 1) { RI = 0; TI = 1; Count = 444; datau[temp] = SBUF; // Read receive data SBUF = 0;// datau[temp]; // Send back same data on uart Count=1; if(temp < 10) { temp =temp+1; } if(temp >10) { temp=0; } uartreceive=1; Count = 444; } else TI = 0; } void main() { AUXR1|=0x00; PCON&=0x7F; SCON = 0x50; // SCON: mode 1, 8-bit UART, enable rcvr TMOD&=0xAF; TMOD |= 0x20; // TMOD: timer 1, mode 2, 8-bit reload TH1 = 0xFA ; // TH1: reload value for 1200 baud @ 16MHz TR1 = 1; // TR1: timer 1 run TI = 1; // TI: set TI to send first char of UART ES = 1; // Enable serial interrupt EA = 1; Count=123; temp=0; while(1) { Delay_ms(100); Count=102; printf("sss\n %u",Count); //My program is getting hangs here if(uartreceive==1) { uartreceive=0; Count=4; printf("Entire array is %s %u\n",datau,temp); Count=105; printf("\nindex %u %c %c\n",temp,datau[0],datau[1]); Count=106; sprintf(datau," "); Count=107; temp=0; uartreceive=0; Count=104; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)