Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic running fast??? 12F629 problems....

Status
Not open for further replies.

SnM

New Member
I got a new problem. I programed my 12F629 chip and the program seems to be running fast. It tests perfectly in MPLAB 7.0. I have a 5 minute delay in my code. with the stopwatch in mplab, the delay is exactly 300 seconds (5 minutes). When i programed my chip, it only ran for about 3 minutes and 15 seconds. I don't know where else to look for any problems.

I am calibrating the 4 mhz internal clock with:
bsf STATUS, RP0 ;Bank 1
call 3FFh ;Get the cal value
movwf OSCCAL ;Calibrate
bcf STATUS, RP0 ;Bank 0

I have set up the configuration bits with 01C4h, which is data/memory code protection off, BOD enabled, MCLRE internal, PWRT enabled, WDTE disabled, and INTOSC no clock output.

The only other thing that can effect my program running, is in my TMR0 interrupt. I have setup the interrupt to happen every 1ms. my program runs through once, and then waits for the interrupt, and then runs though again afterwards. It runs perfectly on MPLAB, so I wouldn't think that would be the issue.

any help would be great.... I don't know where to look anymore. I have tired a few chips, with the same exact results. :(

Thanks,

Steve
 
With TMR0 generating an interrupt every 1mS, that's 300,000 interrupts in 5 minutes - if each interrupt takes 50 instruction cycles that will account for 15 seconds extra over 5 minutes.

As you're already generating timer interrupts, why not use this 1mS clock to generate your 5 minute delay?.
 
well, my problem is that the 5 minute delay is only delaying for 3 minutes 15 seconds. My interrupt routine only clears the interrupt stuff, and then goes back to the beginning of my program. with the 1ms interrupt my program runs every its code every 1ms. i have 3 timers to equal 5 minutes...

timer1 = .250
timer2 = .240 : timer 1 and 2 equal 1 minute
timer3 = .5

.001 seconds X 250 = .25 seconds
.25 seconds X 240 = 60 seconds
60 seconds X 5 = 300 seconds, or 5 minutes.

MPLAB simulates it perfectly.....
 
It works fine now... nothing wrong with my code at all.....
Turns out my 5v regulator was installed backwards, and was outputing over 9volts! :oops: I know I checked it when I put it in though.... I believed I checked them because I got new ones, and I wanted to make sure they worked, so I would have checked the voltages..... oh well.... no harm done.

The pic doesn't seem to have any problems with it after running on 9volts for a while.... it just overclocked the thing. never got warm or anything.

anyway... thanks for your help!
steve
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top