Can anyone help with this one?
I am using the following standard CCS code.
char timed_getc()
{
long timeout;
char retval;
timeout = 0;
while(!kbhit()&&(++timeout<50000))
delay_us(10);
if(kbhit())
retval = fgetc(HIO); //Input Stream
else
retval = 0;
return(retval);
}
Everything works fine for rapid input of up to 3 characters. If I input 4 or more in rapid succession it prints the first three and then just ignores any further data until I do a reset. I was expecting it just ignore the extra inputs. I understand that the chip is processing one character and buffering a further 2 in hardware. I can send three characters and the a further one when the 1st has been handled, or can wait until all three have been read, then send another three etc. I really cannot see why instead of just ignoring extra input, it no longer accepts any more data at all. So far I have not done the hardware, just a Proteus simulation. Is it likely that the simulation is the problem, rather than the function. I have a simulated terminals for I/O observation, problem as follows
input a,b,c rapidly
prints a,b,c
Can then carry on and do same again when printed
input a,b,c,d rapidy
print a,b,c then ignores any more data until reset.
Any ideas would be very helpful.
Added after 1 minutes:
Forgot to mention HIO is the main hardware serial port.