Hi, Johan

When happening ... the first reflex is to open the datasheet and look to the functions connected to the "faulty" pins ...

have a look to pict $ 5.1 ...

Here we also find an ANALOG Comparator ...

so, let's disable it !!!

CMCON = 7 ( from the table $13.1 )

By the way, we don't need the voltage ref nor ...

CVRCON = 0


So, I did forget some littles things ??? ...

Alain