PDA

View Full Version : 10F206 not running code



johnmatt1
- 27th September 2021, 15:16
Please allow me to get the setup info out of the way.
PIC 10F206 genuine from Microchip directly.
Picket 2 ( has the OSCCAL auto-regeneration )
very simple flash test hex file
PICBASIC PRO 3 compiler

the code
*************************************
BLUE var GPIO.0
WHT var GPIO.1


Main:
high WHT
pause 100
low WHT
pause 100
high WHT
pause 100
low WHT
pause 250
high BLUE
pause 100
low BLUE
pause 100
high BLUE
pause 100
low BLUE
pause 250
goto main

*************************************

When I compile and load the hex file nothing happens.
Pickit2 VDD ON and MCLR off (unchecked)
If I run the auto OSCCAL regeneration routine and then reload the hex file it runs.
Turn off VDD and then back on, the program does not startup.
If I MANUALLY enter the OSCCAL value, load the hex file, no run.
Do the auto regen routine, load the hex, it works.
I tried two similar hex programs, same results.
There seems to be some state the PIC is left in after the auto OSCCAL routine which allows the program to
start after loading the hex file. VDD MUST BE ON WHEN WRITING TO THE PIC. If you fail to have it on during the
program writing, turning it on afterwards will not work. But once you perform that auto-regenerate routine, and the VDD is on,
you can load either hex test file and it will run. You cannot turn VDD off and then back on, or it will stop running.
Connecting the PIC to an external power source yields the same result as turning VDD off then back on, it doesn't run.

The OSCCAL value does not change after running the auto-regenerate routine. Mine is 0C14
The config is 0008.
Wisdom please.

HenrikOlsson
- 27th September 2021, 19:04
Can't say I know what makes it run when you manually fiddle with the OSCCAL value but please repeat after me: I shall always check if analog functions are available on the pins I'm about to use. ;-)

I opened the 10F206 datasheet and - sure enough - it's got a comparator which takes precedence over normal GPIO operation. You need to disable it in order for normal digital GPIO operations to work properly. Again, I can't explain how that would tie in with the OSCCAL thing but lets first see if the comparator is indeed the issue.

/Henrik.

johnmatt1
- 27th September 2021, 20:03
Henrik,
You nailed it!
CMCON0 = 0 ' turn off comparator
Works like a champ. I can power off and on all day with no issues.
Thank You
John