Tapio,

Another thing to try ....

Remove the thermocouple input from RA2 and replace it with a known voltage input (from a voltage divider or pot). With this, you should be able to determine if the problem is from the software side or the hardware side. Just a thought ...