sample program of decoder function at Rabbit4000

Is there any sample program for decoder function on Rabbit4000?

I use the following code to test the decoder:

//start of sample code
#define QD1_USEPORTD // use port D pins 1 and 0
void main()
{
long reading;

qd_init(1);
qd_zero(1);

while(1)
{

         	reading = qd_read(1);
	printf("qd1: %10ld      

", reading);
waitfor(DelayMs(500));
}
}
//end of sample code

Then I use a function generator to output a square wave to PD0(QRD1B), the decoder value read by this program is always 0 or 1: “qd1: 0” or “qd1: 1”, why it happened?

Thanks!

A square wave on one channel is not a quadrature signal. A quadrature signal is two signals that never transition at the same point, but both do transition. It is the sequence of transitions and their direction of transition that is used to determine whether the counter is incremented or decremented. An incrementing sequence can be simulated by two square waves, one on PD1 and the other on PD0 with a 90 degree phase shift. A decrementing sequence can be simulated by two square waves, one on PD1 and the other on PD0 with a 270 degree phase shift. Please see section 22 of the Rabbit 4000 Microprocessor User�s Manual for more detail on this subject.