Hi,
I have written a code for serial communication between RD2 and PC, the code is as follows
Timer 2 is used to generate the baud rate for the serial port, timer 0 is used as interrupt to decrement the counter
putch function is polling based serial transmit function
void main(void)
{
......
while (1)
{
putch('a'); // Send data to PC
// wait till counter exhausts or sensor signal obtained
while((MX1Y==1) && (enm==1))
{
MXCLK= MCLK; // Give clock pulses
}
putch('b');
} //end of while(1)
}//end of main
void putch(unsigned char txdata)
{
SBUF=txdata;
while(TI==0)
{
}
TI=0;
}
The problem is that after sending the first character 'a' to PC the counter starts decrementing in the timer 0 interrupt, but after counter is exhausted or the sensor signal is found the while loop breaks and send the 'b' character to PC but the character is not received on PC. And after that any serial communication is disabled!!!!.
Can anyone tell me the reason why serial communication is disabled after the while loop...
Regards,
Amol