The oscillator configuration register is used for adjusting the clock of the microcontroller. The clock is of direct influence on the speed of execution of instructions. It is thus essential that the clock is selected correctly. It is also essential to select the oscillator source. The source can be the internal RC oscillator (FRC – internal fast RC oscillator, LPRC – internal low power RC oscillator) or external oscillator (ERC – external RC oscillator, XT – external quartz).The internal RC oscillator is insufficiently accurate for the majority of microcontroller applications. It is its dependence on the supply voltage and temperature that makes it unacceptable. Besides the internal RC oscillator, it is possible to use an external crystal resonator as a source of the clock. Its frequency could vary from 200kHz to 25MHz. The trird option is to use an external clock (external oscillator or the clock from another instrument). If an external source of the clock or a crystal resonator is used, it is possible to use the internal PLL and increase the internal clock (the clock of the execution of instructions) by factor 4, 8, or 16. The internal clock, of period TCY, controlling the execution of instructions, is obtained when the clock (from the PLL or directly) is divided by 4. Let a 10MHz crystal resonator and PLL 4x are selected. This means that the internal clock is 4x10MHz =40MHz. This value is divied by 4 to obtain 10MHz (100ns period). This implies that one instruction is executed in 100ns, the internal clock period. In the majority of processes it is very important to know the times of the execution of parts of the program. For these calculations it is necessary to know the internal clock period of the microcontroller. The oscillator configuration register: selects the source of the clock, controls the activation and mode of thePLL, enables the permission to switch to another source of the clock during operation, and controls monitoring of the clock. The family of dsPIC30F microcontrollers has the ability that during operation, if it becomes necessary (e.g. one source of the clock fails), can switch to another source of the clock. This ability provides a whole spectrum of applications of the dsPIC30F family of microcontrollers. It is possible to provide an additional stability of the clock, switch to a faster source of the clock within the parts of the program that have to be executed faster, swith to the low power operation, etc. The structure of the oscillator configuration register is given in Table 2-1.
FCKSM <1:0> - Clock switching selection Clock monitoring selection 1x - Switching between different sources of the clock is disabled. Clock monitoring is disabled. 01 - Switching between different sources of the clock is enabled. Clock monitoring is disabled. 00 - Switching between different sources of the clock is enabled. Clock monitoring is enabled. FOS <1:0> - Definition of the clock source. 11 - Primary oscillator selected by FPR<3:0> 10 -Internal low power RC oscillator 01 -Internal fast RC oscillator 00 - Low power 32kHz internal oscillator (timer 1) FPR <3:0> - Selection of the mode of generating the internal clock 1111 - EC PLL 16x - External clock mode with 16x PLL enabled. External clock at OSC1, OSC2 pin is I/O 1110 – EC PLL 8x - External clock mode with 8x PLL enabled. External clock at OSC1, OSC2 pin is I/O 1101 – EC PLL 4x - External clock mode with 4x PLL enabled. External clock at OSC1, OSC2 pin is I/O 1100 – ECIO – External clock mode without PLL. External clock at OSC1, OSC2 pin I/O 1011 – EC – External clock mode. OSC2 pin is system clock output (Fosc/4) 1010 – Reserved 1001 – ERC – External RC oscillator mode. OSC2 pin is system clock output (Fosc/4) 1000 – ERCIO – External RC oscillator mode. OSC2 pin is I/O 0111 – XT PLL 16x – XT crystal oscillator mode with 16xPLL enabled. 4 – 10MHz crystal 0110 – XT PLL 8x – XT crystal oscillator mode with 8xPLL enabled. 4 – 10MHz crystal 0101 – XT PLL 4x - XT crystal oscillator mode with 46xPLL enabled. 4 – 10MHz crystal 0100 – XT - XT crystal oscillator mode (4 – 10MHz crystal) 001x - HS - HS crystal oscillator mode (10 – 25MHz crystal) 000x – XTL - XTL crystal oscillator mode (200kHz – 4MHz crystal)