The DCO frequency can easily be calibrated using an external clock source or any known value pulse-width. Here the example shows a 4096 clock source from A Clock divided by 8 as the reference source. In this case, there is code and a timer involved to count the number of DCO clock pulses that fit inside of one of the 4096 hertz clock pulses. Comparing the measured DCO frequency to the desired DCO operating frequency, its registers can be decremented to slow it down or incremented to speed it up. This can be done in an iterative loop until the correct number of DCO clock pulses fit inside of one of the reference clock pulses. In this way, it’s not necessary to know exactly where the DCO is, how far away from the desired frequency it needs to be, how to set the DCO bits, how to set the MOD bits, etc. Simply count the number of pulses that fit and increment or decrement the DCO bit settings until the pulses are at the desired number. In addition, using an external ROSC helps to reduce the temperature variability of the DCO. In this case, an external ROSC of 100K results in a DCO clock frequency of approximately 2 megahertz.