Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

whats the probplem with 12f675

Status
Not open for further replies.

welove8051

Full Member level 6
Joined
Jul 16, 2009
Messages
357
Helped
51
Reputation
102
Reaction score
41
Trophy points
1,308
Location
india
Activity points
3,277
hello all, i am unable to program 12f675 with pickit 2, it is showing the error as

invalid OSCCAL value detected

what is OSCCAL and how to solve it


regards
kj
 

Hi ,

If you are using the internal oscillator then you need to use this code as shown in the datasheet - oscillator section.

See also the 12F675 Termplate file in MPASM\ TEMPLATE \ CODE which shows you a basic program code set up.

Code:
		call    0x3FF             ; retrieve factory calibration value
		bsf     STATUS,RP0        ; set file register bank to 1 
		movwf   OSCCAL            ; update register with factory cal value 
		bcf     STATUS,RP0        ; set file register bank to 0
 

ok. how to rewrite the osccal value back to it using pickkit2 or other means

regards
kj
 

If you have a Pickit2, you are fortunate; it has an auto osccal generation feature that will calculate the correct osccal value for you, and write it back into the right address.

From the Pickit2 app.,

Tools -> OSCCAL -> Auto Generate.

Regards,

Anand
 

hi, i am using pickkit2 lite. pickit2 unable to write the osccal value manually or automatically.
i am confused.. can any body provide a step by step procedure.
 

The Pickit2 lite, as against the Pickit2, has no control over Vdd. Therefore, it will have problems with devices which require Vpp-before-Vdd, especially when internal oscillator is selected and MCLR is disabled. You'll have problems not just with OSCCAL, but any write operation.

Try using the "Use Vpp first program entry" from the Tools tab; might work or might not.

Would be best to buy / build a clone that controls the Vdd line.

Regards,

Anand
 

Going back to the source of the original problem, the reason the error was reported is that the value in the last memory address is not within a valid range. You can ignore the error but the PIC may behave strangely, depending on your application. It works like this:
1. Before the PIC leaves Microchip's factory, they test it and measure it's internal clock speed. Due to manufacturing tolerances, the frequency may be a little way off what it should be.
2. Cleverly, Microchip built a system into the silicon that allows the oscillator frequency to be pulled one way or the other to bring it back into specification. This is done by loading a value into the OSCCAL register.
3. Microchip code the value they calculated would calibrate the oscillator into an instruction "movlw xx" where xx is the calibration value, then store it in the highest memory address (the reset vector).
4. The memory addressing rolls over when it reaches the highest address and goes back to the beginning, address 0. So when reset it executes the instruction at the reset vector and goes to address zero with the calibration value in the W register.
5. Now it's up to you, the address is zero so it's a good place to start your program and the calibration value is available if you want to use it. If you use an external oscillator or crystal you don't need it so just program away to your hearts content, if you are using the internal oscillator, make your first instruction "movwf OSCCAL" and from then on the oscillator runs at the right frequency.

The reason you get the failure message is that the instruction in the highest memory address is not "movlw xx", almost certainly because the whole memory has been erased. When erasing the PIC, the Pickit2 will read the last address, erase the memory and then write it back again so the calibration value is preserved. It does have a facility to regenerate the value again if it gets wiped. I'm guessing here that it loads a small program into the PIC, times it's execution and works out the value needed to speed it up or slow it down, then erases the program and write the result into that last address. Variations on the real Pickit2 may not have this ability.

As a last resort, you can manually make it work by coding "org <highest memory address>" then "movlw 0" in your program to fake the value. Zero is the mid way calibration figure so it won't be too far off.

Brian.
 

if you scroll down to the end of the Program menu, the last location stores the OSCCAL data. This value is invalid because it should be of the format 34XX where XX is an 8 bit value whose top 6 bits are used. It looks like the PIC is not being programmed by your programmer. what happens when you erase the device? If you are using the PIC KIT 2 clone to power the PIC, try and reduce the voltage to about 4.7 volts. Also have you verified that your PIC KIT works on any other device?
 

to spiralbrain
pic kit is well working other controllers. what ever the operation i do i get the osccal error.

to betwixt
i understand the problem. now help me to solve it. i tried pickit auto calibration method it doesnt work. can u brief me how restore the ic.
is it necessary to write a code in starting of every program for 12f675 that. we should read and write the same in osccal register. iam using hitech c in mplab.

like

void main()
{
osccal=_read_osccal_data();


}
 

Unfortunately, that wont work. If you write in assembly language you can write any instruction at any address so it's easy to make the first instruction "movwf OSCCAL" but in other languages, particularly high level ones like 'C', the compiler produces extra code and it places it wherever it decides. I do not use Hitech, it's too expensive for me so I can't help but I would imagine there is something in the Hitech configuration that forces it to place the instruction automatically.

In my PicKit 2 there is an option under the 'Tools' menu to regenerate the OSCCAL value. You have to select the device first or the option is grayed out. Check yours, it should be there.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top