Hi Andrew -
I think you are using the S25FL256S. Correct?
The issue is your system is interrupting the WRR command while it is updating the configuration register. Per AN200381 the best practice is to only use the WRR command while the system is under continuous power. Another best practice is to minimize the usage of the WRR command by always reading the register first to see if it needs changing, and then to use the WRR command only if a change is required. The best case is if you can program the configuration register once during production and to never change it again after that.
The P_ERR programming error flag is set because your WRR command is trying to erase one or more of the OTP bits from 1 (programmed) to 0 (erased). There are two workarounds: 1) avoid the error flag by reading the current state of the OTP bits and don't try to change them from 1 to 0 using the WRR command; and 2) if the error happens use the CLSR command to clear the P_ERR and WIP flags to return the device to standby mode so that it can accept commands. There are three OTP bits, and once they are programmed to 1 they cannot be erased back to 0.
The latency codes are non-volatile, so a WRR command can always change them back to the setting that works with your system. So if you can execute startup code while in single-IO mode, you can check the register state and correct the latency codes.
I hope this helps!