What CONFIGs are you using?
I don't see any oscillator setting and no mention of what osc you are using.
Robert
EDIT: What about this?
Note:
Erasing the device will also erase the preprogrammed internal calibration value for the internal oscillator. The calibration value must be read prior to erasing the part so it can be reprogrammed correctly later.
Suggestion: Do a small test program using only the LED pin and a loop turning it on and off. Get the PIC running properly first, then add the sensor logic.
And I just have to ask, why use what appears as an archaic PIC? You have a truckload at 1 penny per dozen sitting in the yard?
Bookmarks