Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F4520 Serial Simulation Problem.

Status
Not open for further replies.

GrandAlf

Advanced Member level 2
Joined
Mar 9, 2002
Messages
520
Helped
47
Reputation
92
Reaction score
6
Trophy points
1,298
Location
UK
Activity points
4,730
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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top