Here is an excellent article on this problem that everybody should be aware of.
Mainly the problem is that when you read a PIC PORTx I/O, you read the input buffer, not the output latch for pins that are defined as outputs.
Some latest processors have separate output latches named LATx that are readable. In this case, the read-modify-write problem does not apply, just use PORTx for inputs and LATx for outputs.
How problems may occur: if the output pin has some load that makes the requested level to not be reached (by an excessive pullup or pulldown, by an heavy capacitive load such as a mosfet gate) the "input" may not reflect immediately (or never at least) what you "output"; so a code like:
BSF PORTA, 0
BSF PORTA, 1
may write back a 0 on PORTA.0 at the 2nd instruction (yes, a BSF reads the whole port, changes the bit and writes back to the whole port).
another example:
MOVLW h'FF'
MOVWF PORTA
XORWF PORTA, f
After this, all pins should be 0, may be not: at the third instruction PORTA is read back before computing the xor, so it may read some zeroes...
What about PMP?
PMP allows direct port write that maps directly to the shortest processor's instructions, so the above remarks apply:
PORTA := 0;
PORTA.0 := true;
PORTA.1 := false;
may write back a 0 on PORTA.0 at the 3rd instruction.
Workarounds:
The simplest way is... Do not use such constructions...
Next, if the problem is due to a capacitive load, some delay may be inserted between writes, to allow the cap to charge, but that's empirical and not bulletproof:
PORTA := 0;
PORTA.0 := true;
NOP(2); // or delay(xxx)
PORTA.1 := false;
Next, if the problem is a only due to a capacitive load, we may wait until the cap has charged, but that would hang the processor if nothing happens:
PORTA := 0;
PORTA.0 := true;
repeat until PORTA.0 = true; // wait for capacitance charging
PORTA.1 := false;
Finally, a bulletproof armor uses a shadow register:
SHADA := 0; // Initialize
...
SHADA.0 := true;
SHADA.1 := true; // start pulse
PORTA := SHADA;
SHADA.1 := false; // end of pulse
PORTA := SHADA;
where SHADA is a global byte variable that will reference / hold all manipulations on PORTA for the whole program and that is systematically copied to PORTA after each block of changes.
To do list:
Future implementation of PMP should contain some mechanism to automatically use a shadow register that should be activated by a compiler directive (since this is time / code consuming and everybody does not need it).