Hello,
Caveat: This probably isn't a GCB problem, but I want to make sure before I add parts
to solve it. It's also quite possible the issue is self-inflicted - I'm a 40-year programmer, but a GCB newbie.
I have a very small project using a PIC12F675 to provide a warmup timer and a few other simple functions. The issue is that the warm-up routine, which counts seconds down from [some number] to zero executes about 10% too fast. I was expecting if it anything to run a smidgen slow due to other instructions being executed in the loop, but 10% sounds like a large number. First, would a 10% internal clock accuracy be considered normal for a PIC12F675? Here's the stripped-down code:
' ** code starts
chip 12F675, 4
config MCLRE = Off, Osc = int
Dim state as Byte
Dim counter as Integer
Dir GPIO.0 Out
state = Off
counter = 90
' ** This loop only takes roughly 80 seconds to execute. ??
Do
If state = Off Then
State = On
Else
State = Off
End If
It could be that the factory calibration bits have been inadvertently erased or corrupted.
If you have a scope or frequency counter you can test by enabling clkout on Pin 3.
#chip 12F675. 4
#config OSC = INTRC_OSC_CLKOUT. WDT = OFF, MCRLRE = OFF
do
loop
Run the program above while measuring the frequncy at Pin 3,. It should be precisely 1 MHz (+- .25%) if not, then the factory calibration has been erased or corrupted.
If you have a Pickit 2 Programmer the calibration can be reprogrammed, but if you do not know the original factory value it will be difficult and may require some trial and error.
Thanks, William. Sorry to reply so long after-the-fact. I ended up scrapping the 12F675's. I got them from an Asian source, so it occurred to me to wonder if them might not have been counterfeit, assuming something as complex as a PIC can be counterfeited profitably...
Regards,
-audiomath (Jim)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Caveat: This probably isn't a GCB problem, but I want to make sure before I add parts
to solve it. It's also quite possible the issue is self-inflicted - I'm a 40-year programmer, but a GCB newbie.
I have a very small project using a PIC12F675 to provide a warmup timer and a few other simple functions. The issue is that the warm-up routine, which counts seconds down from [some number] to zero executes about 10% too fast. I was expecting if it anything to run a smidgen slow due to other instructions being executed in the loop, but 10% sounds like a large number. First, would a 10% internal clock accuracy be considered normal for a PIC12F675? Here's the stripped-down code:
' ** code starts
chip 12F675, 4
config MCLRE = Off, Osc = int
Dim state as Byte
Dim counter as Integer
Dir GPIO.0 Out
state = Off
counter = 90
' ** This loop only takes roughly 80 seconds to execute. ??
Do
If state = Off Then
State = On
Else
State = Off
End If
Loop
' ** code ends
Thanks for any insights,
--jim
I just got a batch of PIC12F683's in the mail, so I tried one with the same code as before other than the chip line nows reads 12F683, of course.
Strangely enough, the program loop now executes within one second or so of being exact, according to the stopwatch in my phone. This is acceptable.
So... I have another 12F675 and I'll try it. Apparently the issue isn't with GCB, or if it is it isn't universal.
It could be that the factory calibration bits have been inadvertently erased or corrupted.
If you have a scope or frequency counter you can test by enabling clkout on Pin 3.
Run the program above while measuring the frequncy at Pin 3,. It should be precisely 1 MHz (+- .25%) if not, then the factory calibration has been erased or corrupted.
If you have a Pickit 2 Programmer the calibration can be reprogrammed, but if you do not know the original factory value it will be difficult and may require some trial and error.
This link has some good information.
http://picprojects.org.uk/projects/piccal.htm
Last edit: William Roth 2015-07-25
Thanks, William. Sorry to reply so long after-the-fact. I ended up scrapping the 12F675's. I got them from an Asian source, so it occurred to me to wonder if them might not have been counterfeit, assuming something as complex as a PIC can be counterfeited profitably...
Regards,
-audiomath (Jim)