Contents
Understanding and Configuring the PIC10F322 System Clock Speed
Upon reset or power-on, the PIC10F322 microcontroller defaults to a system clock speed of 8MHz. This default setting remains until you modify it in your code.
Default Clock Speed and OSCCON Register
When using the internal oscillator for the system clock, the PIC10F322 sets the IRCF<2:0> bits of the OSCCON register to ‘110′ following any reset. This setting selects an 8MHz frequency.
OSCCON: Oscillator Control Register
The OSCCON register controls the internal oscillator frequency with the IRCF<2:0> bits. Here are the bit settings:
OSCCON: OSCILLATOR CONTROL REGISTER
Bits 6-4 IRCF<2:0>: INTOSC (FOSC) Frequency Select bits
- 111 = 16 MHz
- 110 = 8 MHz (default value)
- 101 = 4 MHz
- 100 = 2 MHz
- 011 = 1 MHz
- 010 = 500 kHz
- 001 = 250 kHz
- 000 = 31 kHz (LFINTOSC)
Changing the System Clock Speed
To change the system clock speed, you need to set the IRCF bits in the OSCCON register to the desired frequency. This is done using the following syntax in your code:
OSCCONbits.IRCF = 0bxxx (xxx) is the bit selection from the above list.
For example, if you want to set the system clock speed to 16MHz, you would use:
OSCCONbits.IRCF = 0b111;
If you prefer to set the clock speed to 1MHz, you would use:
OSCCONbits.IRCF = 0b101;
Important Considerations
- Consistency: Always ensure that the
_XTAL_FREQ
macro is defined correctly to match the selected clock speed. This is crucial for delay functions and other timing-related operations. - Power Consumption: Higher clock speeds typically result in higher power consumption. Consider the power requirements of your application when selecting the clock speed.
- Application Needs: Choose the clock speed that best suits your application’s performance needs. For example, lower speeds might be sufficient for simple tasks and can save power, while higher speeds are better for more complex operations.
Summary
By default, the PIC10F322 runs at 8MHz after a reset or power-on. To change this default setting, you can modify the IRCF<2:0> bits in the OSCCON register according to your desired clock speed. This flexibility allows you to tailor the microcontroller’s performance to suit your specific application needs.
Feel free to experiment with different clock speeds to find the optimal setting for your project. The ability to easily configure the clock speed makes the PIC10F322 a versatile choice for a wide range of applications.
Have a Creative or Technical Project in Mind?
Looking for guidance, insights, or a fresh perspective on your technical or creative journey? Or just somebody to chat with?
Reach Out
jamie@jamiestarling.com