Menu

PIC12F675 internal clock fast or ??

Help
2015-07-23
2016-05-10
  • James Barber

    James Barber - 2015-07-23

    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

      Set GPIO.0 = state
      Wait 1 S
      counter = counter - 1
      If (counter <= 0) Then Exit Do
    

    Loop
    ' ** code ends

    Thanks for any insights,
    --jim

     
  • James Barber

    James Barber - 2015-07-24

    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.

     
  • William Roth

    William Roth - 2015-07-25

    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.

    This link has some good information.

    http://picprojects.org.uk/projects/piccal.htm

     

    Last edit: William Roth 2015-07-25
  • James Barber

    James Barber - 2016-05-10

    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)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.