The only other thing I can think of is 20ms period might not be correct for your motor. I've never tried different motors, and I don't know if the frequency is the same. I tried finding that information on your motor, but didn't come up with anything. Next time you buy a motor, make sure you can get the data sheet for it.
You might also try this in your code. The variable temp1 is the "low" value, and is incremented by 2000us each time through the loop defined by the variable "j". Thus, the frequency is varied from 20ms to 40 ms in 2ms increments. Run it and see if you motor reverses at any point.
Code:
temp1 = 20000;
FOR (j = 0; j < 11, j++) {
FOR (i = 0; i < 150; i++)
{
output_high (PIN_A4);
delay_us (2000);
output_low (PIN_A4);
delay_us (temp1);
}
FOR (i = 0; i < 150; i++)
{
output_high (PIN_A4);
delay_us (1500);
output_low (PIN_A4);
delay_us (temp1) ;
}
FOR (i = 0; i < 150; i++)
{
output_high (PIN_A4);
delay_us (900);
output_low (PIN_A4);
delay_us (temp1) ;
}
temp1 = temp1 + 2000;
}
}