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.

BandGap Value Problem - Working Speedily

Status
Not open for further replies.

Suraj143

Active Member
This is my problem! I’m using PIC12F675.

When I use external RC the code works nicely (4.7K & 22pF).

But when I use internal RC the code works very speedily.

I don’t know what is “band gap”. I just placed a value in the last location retlw 20h & called that in the beginning & move it to OSCCAL.

What value to move to last location? Is that the problem to work speedily?
 
Hi thanks for that.

But its the way I'm loading the value.I couldn't solve my problem yet.

By the way I still don't know whats the meaning of bandgap value.
 
You're confusing the Oscillator calibration word with the band gap.

The band gap is used to set the reference voltage used by the Brown-out-detect and Power-on-reset circuits. It is held in the configuration word as two bits and needs to be read out before you erase the device. See 12F675 datasheet page 52

The oscillator calibration word is held at the top of program memory and again needs to be read out before the device is erased or you lose it.

You can recalibrate the oscillator using a PICKit2 with S/W 2.50. If you haven't got a PICKit2 I designed this little project some time ago that will work out the calibration word
PIC 12F629 / 12F675 internal oscillator recalibration utility

By the way Bill, the link to saving the calibration word by writing on the pins comes from my site Saving the oscillator calibration setting for PIC 12F629 & 12F675 :)
 
Hi Pete thanks for clearing that two things "band gap" & "oscillator calibration word "

But if I buy a brand new PIC I dont need to change the oscillator calibration word.I need to call in first part in my program.

Then will it work exactly 4MHz?
 
Changing oscillator calibration word will cause my program to work speedily?
Or more slowly, depends which way you change it.

It will run at 4Mhz +/- 1% if you run it at the same temperatue and voltage that it was calibrated at. I seem to recall reading somewhere that Microchip calibrate at 3.5volts / 25degC

See Figure 13-15 and 13-16 on page 112 of the 12F675 datasheet for a graphs of frequency variation vs supply voltage and temperature.

To set the OSCCAL register just use the code below and off you go.

Code:
bsf STATUS, RP0              ;Bank 1
call 3FFh                         ;Get the cal value
movwf OSCCAL                 ;Calibrate
bcf STATUS, RP0              ;Bank 0
 
Ya thats how I call but I'm still struggling what is this "oscillator calibration word "?

I know factory comes with a value.When I read a brand new PIC it shows 3440H (retlw 40h).

I mean whats the relationship between this value & the operating frequency?

This is the place I need to know.
 
Ya thats how I call but I'm still struggling what is this "oscillator calibration word "?

I know factory comes with a value.When I read a brand new PIC it shows 3440H (retlw 40h).

I mean whats the relationship between this value & the operating frequency?

This is the place I need to know.

It's a value measured in the factory to make the oscillator as accurate as possible - different PIC's will obviously usually have different values.

Your programming software should automatically read, save, and restore the value during programming or erasing.
 
I see now.Then of course changing this value will vary the frequency a lot.

I think that will be one problem to speed up the output than I expect.

Better checkout the CLKOUT frequency with a frequency meter & tuned the OSCCAL value.
 
Ya thats how I call but I'm still struggling what is this "oscillator calibration word "?

I know factory comes with a value.When I read a brand new PIC it shows 3440H (retlw 40h).

I mean whats the relationship between this value & the operating frequency?

This is the place I need to know.

Again, read the data sheet, page 16, 2.2.2.7 OSSCAL regsister.

The register uses the 6 high order bits to adjust the oscillator frequency with 111111xx being highest frequency it can adjust to and 000000xx the lowest. 100000xx is the centre of adjustment but not neccesarily the point at which the oscillator will run at 4Mhz.

There is no specifc relationship between the value and the frequency - you can't say an increment of 1 will increase the freqency by 15Hz if that's what you mean. Even if you find some relationship between the OSCCAL values and clock frequency for a particular device it may not hold for devices from another batch.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top