how do you timeout waiting for data back from the JackRabbit?

How do you wait for serial data coming back from the processor?

What flags do you look for or wait on?

I tried all the followings conditions for timeout and none of them seem to work.

while(serDpeek()==-1)

while(BitRdPortI(SDSR, SS_RRDY_BIT) == 0)

while(serDrdUsed()<7)

Here is a complete while loop for timeout.

t = MS_TIMER;

while ( serDpeek() == -1)
{
if (MS_TIMER>(t+100)
break;
}

serDpeek always returns as though there is data to read when in fact no data has been received. With SDSR, SS_RRDY_BIT flag, it always indicates that port D is ready for reading. As for as serDrdUsed function goes, I have no idea what it is doing.

Take a look at samples\serial\EchoChr.c. This program waits on serDgetc() to return success (0)

Here is the function description:

SYNTAX: int serDgetc(void);

DESCRIPTION: Get next available character from serial port D read buffer.
This function is non-reentrant.

PARAMETER1: None

RETURN VALUE: If successful, the next character in the low byte and 0 in
the high byte of the integer result;
otherwise, the integer -1 which indicates either an empty
or a locked receive buffer.

1 Like

Thank you so much.