What Lundin said +
erase didn't work because JACOBO didn't clear CBEIF flag, he only wrote erase command to FCMD. Some more thoughts:
1) FPROT=0xFF doesn't make sense in normal modes. You can protect flash, but can't unprotect it.
2) FSTAT = FSTAT | 0x30; <-- this is wrong. It clears not only ACCERR and PVIOL, but also all flags that are set! FSTAT flags are clearable by writing '1' to them. Use either
FSTAT = 0x30;
or
FSTAT &= 0x30; // note the difference between FSTAT &=0x30 and clearing
// bits in regular RAM variable, x &= ~0x30;
To clear CBEIF either use
FSTAT = 0x80
or
FSTAT &= 0x80;