Tunning internal oscillators
Posted: Mon Jun 25, 2012 12:49 pm
I wanted to tune the frequencies of 2 microcontrollers with only internal oscillators to get frequencies as close as possible to each other.
The solution is easy. Just tune 1 microcontroller by means of the byte OSCTUNE with bits TUN <5:0>. This can be made visual with software RS232 outputs of both microcontrollers. Compare them e.g. with an oscilloscope *).
By means of an external voltage with ADC the TUN values can be changed. The TUN values are shown on a LCD. If the frequencies are equal the TUN value is known and can be set for that microcontroller.
See the flowcode used in the attached file.
I found a frequency shift possible of +/- 10%.
Kind regards,
Jan Lichtenbelt
*) If you do not have an oscilloscope, it is possible to compare the 2 signals (one inverted) and integrate the output (just an RC circuit) until 0 is reached.
The solution is easy. Just tune 1 microcontroller by means of the byte OSCTUNE with bits TUN <5:0>. This can be made visual with software RS232 outputs of both microcontrollers. Compare them e.g. with an oscilloscope *).
By means of an external voltage with ADC the TUN values can be changed. The TUN values are shown on a LCD. If the frequencies are equal the TUN value is known and can be set for that microcontroller.
See the flowcode used in the attached file.
I found a frequency shift possible of +/- 10%.
Kind regards,
Jan Lichtenbelt
*) If you do not have an oscilloscope, it is possible to compare the 2 signals (one inverted) and integrate the output (just an RC circuit) until 0 is reached.