I wish I could be more help with the 18F2431 chip. Unfortunately, my experience is mostly limited to the mid-range and enhanced mid-range chips (e.g., 12F6xx and 16Fxxx or 16F1xxx chips). Whatever I say about the 18F chips is based on a brief comparison to the 16F series. My comment was generic, and as a note of interest, I was pointed in the right direction by the same Microchip forum that atferrari referenced.
You need to refer to the section in the datasheet that describes the memory organization. The Special Function Registers (SFR's) are described beginning around p. 65 through p. 69. I am sure you have used them, but may not have known them by that name.
The registers that specifically caused me problems are, using 16F nomenclature, the "Common Ram" and "General Purpose Ram." On the 18F, it appears Common Ram is still present (Bank0, 060h-05Fh; Bank1, 100h -1FFh; and Bank2, 200h - 2ffh). Note, those are 12-bit numbers and the first bit identifies the memory bank. The 18F has what is called "Access Ram" (000h-05Fh), which is 96 bytes. From my brief read, it appears those ram locations can be accessed from any bank in a single cycle and so might be considered analogous to the 16F "Common Ram" that can be accessed in a single cycle from any bank as well.
View attachment 91518
I was all set to post my Assembly program for clearing those registers, but after seeing atferrari's post, his code is probably more applicable to your situation. Our approaches were similar. I simply set up indirect accessing, cleared one register, incremented the file select register (FSRx), cleared the next register, and so forth.
In my case, the problem was created by using a Common Ram register for various flags. Those flags were not reset on re- programming and thus made the chip run erratically. For example, if an interrupt sets a flag for something and that flag is not cleared, your interrupt routine may see that "left-over" flag and not behave as you want it to behave. Of course, on the chips I am familiar with, clearing those RAM locations doesn't take long.
atferrari's routines also address the SFR's. He added a note of caution about erasing an SFR.
John