I case you haven't already, you should probably post this on the Microchip forum. And you should check the errata for that device. And if that fails, open a ticket with Microchip customer support.
There are some other things that could be causing this, though, so make your list and check it twice. It's probably essential (or at least easiest and most efficient) to make a simpler test code just to verify that the cause-effect is what you think it is, rather than due to a bug in the code.
Some devices, for instance, you have to wait a discrete amount of time after startup/powergood before you initiate a write.
And you have to make sure your write is not interrupted (i.e. disable interrupts before any write, and reenable after it is finished).
This is maybe noob stuff, which you already know. But these are reasons to write a simple test code to isolate the problem.
So you might get a lot of other questions if you ask around. But there's a much better chance of someone else having had the same problem as you, if you post at Microchip.