Hi,
You're suffering from what is called a RMW problem (read-modify-write). The way the PIC works when setting a single bit in a register, like the GPIO-port in this case, is to first read the whole register, then set the bit in question and finally writing the whole register "back".
Because your motor presents a large a load to the pin (especially at startup) the voltage on the pin will sag or be low. So what is happening is this:
First you have the High 2. This reads the port (as a byte), sets bit 2 and writes the whole byte back to the port.
Now you have High 1 which does the same thing but because pin2 is heavily loaded it will read as 0 when the port is read, the PIC then sets bit1 and write back to the port resulting in bit 2 now being reset to 0.
The best bet is to use a transistor to drive the motor. If that's not an option then write to the port directly, setting both pins at the same time. You do this in the same way as Darrel showed you how to write to CMCON etc - look up the physical adress of GPIO and use POKE to write to it.




Bookmarks