l293d interfacing with pic16f877a
Kaleborg is partly right: “j<5000000 is always true”, but not because of a 8-bit uC, but because j is an ‘int’ (j € (-32768, 32767) ), and if your compiler did not complain about this, you should change it!
If you make j an ‘unsigned int’, it can then go up to 65535.
But that’s only part of the problem!
In your ‘wait()’ function you do ‘RD1 = 0’, so that any previous attempt to do otherwise (‘RD1 = 1’) in main() will only last about a couple us, so the correctness with which you time ‘DelayUs()’ is irrelevant.
Arthur