Does the code that works include DEFINE OSCCAL_1K 1..?
This define places a call to program location 03ffh. If your device programmer has erased this location, then using this define will cause a continuous loop.
I.E. call 03ffh, wrap around back to 0, land on call 03ffh again, etc,,
Location 03ff has a retlw xx instruction. xx is the factory oscillator calibration value returned by the retlw instruction.
I read one of my 12F629's with my programmer. This is what's read from location 03ff.
03ff- 3494
34 is the retlw instruction. This should always be the same. 94 is the factory oscillator calibration value (for this particular 12F629) returned in w when call 03ffh is issued.
If your programmer has erased this, you have a few options.
1. Remove the DEFINE OSCCAL_1K 1, and use the default value that's already in osccal. That eliminates to continuous loop if the retlw xx at location 03ffh has been erased.
2. Replace DEFINE OSCCAL_1K 1 with osccal = xx (xx is the value to load into the osccal register). You'll need to experiment to find the optimum value if you didn't read & record the value before programming/erasing your 12F629.
3. Use the PBP pokecode command to replace the retlw xx at location 03ffh.
Assuming 94h is the calibration value you find works best, then pokecode @$3ff, $94 would place retlw 94 at location 03ffh, and you could then use DEFINE OSCCAL_1K 1 again.
Your code above works fine as-is on the 12F629 I programmed, but I have my programmer (meLabs serial programmer) setup to not erase or re-program the calibration value at 03ffh.
I'm not sure what would cause it to not be re-programmable unless your programmer is over-riding config fuse settings in your .hex file and setting code protection. Then you have to erase the part before re-programming.
What programmer are you using?
Can you read the 12F629 to verify location 03ffh is blank or has the retlw xx?
Can you erase the PIC?
Bookmarks