the only time I have experienced anything similar was trying to use a LAT pin in the I2COUT command . i2c worked ok but other code got wrecked seemingly at random .
dt sorted for me , reason is a lot of commands like i2c etc set the tris reg by adding a fixed offset to the port address works fine for PORTX fails miserably for LATX . its not a trap I will fall into again .
I wonder if the problem could be tracked with source level debugger , it would probable be a tedious exercise though .




Bookmarks