ATTiny15 crystal calibration

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I want to use one ATtiny15 to calibrate the internal clock of another one. The master would generate a slow clock of 1.6KHz by dividing down the main clock of 4MHz. It would trigger a timer in the slave micro. The slave would compare counts in that register to it's own internal clock. It would modify the calibration register until they match. Then it would store the result in EPROM. All successive programs for that slave chip would always look at the specific location for the calibration value to calibrate itself before running it's program. Has anyone already done this with this mirco or with another micro with it's own internal clock? Any suggestions would be appreciated.

Thanks, Scott Pierskalla

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

What sort of application do you have that needs this sort of tuning ?

The oscillator frequency is going to drift over time with temperature and as the parts age, so even if you calibrate it, it may mean nothing a week later.

Expensive timebases keep their oscillator temperatures constant by building little ovens for them to operate in. It is easy to keep a small space temperature constant within a very small temperature range, and then the oscillator operating within it is very stable.

In summary, I don't think you'll be any better off with this calibration than with the raw crystal frequency unless you go to some other extreme measures.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps I didn't provide enough background information on the ATTiny15 micro. Here is a paragraph from the datasheet.

Internal Oscillators
The internal oscillator provides a clock rate of nominally 1.6 MHz for the system clock CK. Due to large initial variation (0.8 MHz -1.6 MHz) of the internal oscillator, a tuning capability is built in. Through an eight bit control register OSCCAL,the system clock rate can be tuned with less than 1% steps of the nominal clock.

I want to use the internal oscillator. I want the frequency to be 1.6MHz to within the 1% that Atmel specifies. I want to be able to program the micro with the calibration code, calibrate the oscillator automatically (instead of by trial and error), and then program the micro with the final code. After the calibration is done, I don't care if the frequency drifts a little.

I need to measure the pulse width of a 50Hz signal which will be 5% to 10% duty cycle and then produce a 2Khz output signal with a 0% to 100% duty. The 1.6MHz internal clock will make the math in assembly very easy.

Thanks, Scott

admin's test signature