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.

OSCCAL problem

Status
Not open for further replies.
We are using pic16f676, mikrocpro for pic and pickit2v2.61 writer. The problem is that for the same program of a timer on the same hardware, we are getting different timing values for different ICs, i.e. for 1 IC, it is 1 minute, for other it is 1 minute 3 sec. etc. We have changed the osccal value in writer, but it doesn't accept the change.

Also, in the code, if we change osccal value, then it changes the timing value but the difference still remains for different IC. Kindly help us.

Thank you.
 
The OSCCAL has to be loaded from the location 0x3FF... BUT!!! if you have erased the chip this value will be gone...

The pickit 2 has a facility to calculate a new one.... I have used this on the pic12f675 and the OSCAL literal at 0x3FF is usually true to accuracy..... The other value is the band gap calibration bits.... These also must not be changed as they differ from chip to chip... Pickit 2 can calculate these as well...
 
I haven't any pic16f676 chips to look at.... If you make a setup that will change the value of OSCCAL with up down buttons and out put the value of the OSCCAL on LED's then you can write them down... Just output the OSC on the OSC2 pin and check with a frequency counter!!
 
OK. But can you suggest whether there is problem in writer itself that doesn't cause change in OSCCAL value. Or there is problem with demo version of mikrcpro for pic, because when I see the asm part of my C code, there is an instruction MOVWF OSCCAL+0. There is nothing like RETLW 0x3ff, which, I think, is for calibration. Thanks in advance.
 
Have you included the ASM portion that retrieves the value...

Add This to your Init routine

asm {
BSF STATUS, RP0 ;Bank 1
CALL 0x3FF ;Get the cal value
MOVWF OSCCAL ;Calibrate
BCF STATUS, RP0 ;Bank 0
}
 
I added what you suggested and it worked!!! Other mistake , as you mentioned previously, was that I was trying to erase and set another OSCCAL value to the IC, which resulted in large timing gaps between two ICs. Now, I am having maximum timing difference of 1 second for 2 minute's timer, among no. of ICs, which , I think, is due to inbuilt OSCCAL value and, is unavoidable.
THANKS A LOT for such useful and prompt replies.
Regards.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top