Crystal oscillator
Quartz Oscillator 3225 20M OSC

First let's talk about what is a clock. The clock is the heart of the microcontroller. Every beat. The individual circuits of the entire microcontroller are synchronized. It's like the beat of the broadcast on the radio when we do the broadcast gymnastics 1234 2234 3234. . . . Then all of our classmates performed one action at this rhythm. The faster the beat, the faster we move. The slower the beat, the slower we move.
Internal clock and external clock?
There are many models of PIC microcontrollers that can be set to use an external clock (such as an external 4MHZ quartz crystal) or an internal RC clock. And there are many models that can choose a clock with multiple frequencies.
For example, the PICLF1823 internal clock can reach up to 32MHz and the minimum can reach 31kHz. This actually provides a new way to reduce power consumption. A typical MCU reduces the power consumption often used for sleep, while the CPU does nothing during sleep. If you want to reduce power consumption, and the CPU can work. Reducing the clock frequency is definitely a very good choice.
Clock settings?
The clock setting is generally only related to two places. One is the configuration word, and the other is the oscillator control register OSCCON. Let's take PICLF1823 as an example.
The clock associated with the PICLF1823 Configuration Word setting is the FOSC: Oscillator Select bit, and the PLLEN:PLL Enable bit.
OSCCON is about the internal clock frequency selection and is ignored if only an external clock is used. The following is a detailed description of the OSCCON registers in the data sheet.

Example explanation:
Set the clock frequency to 8MHZ using the internal clock
Development environment: MPLAB X IDE
Chip model: PICLF1823
#include
__CONFIG(FOSC_INTOSC&WDTE_OFF&PWRTE_ON&MCLRE_OFF&CP_ON&CPD_OFF&BOREN_ON&
CLKOUTEN_OFF&IESO_ON&FCMEN_ON);
__CONFIG(PLLEN_OFF&LVP_OFF) ;//Set the FOSC: oscillator select bit to INTOSC,
Void init_fosc(void)
{
OSCCON = 0x70; // 8MHZ IRCF clock frequency selection bit set to 8MHZ
}
Int main(int argc, char** argv) {
Init_fosc();
While(1);
}
What is the PLL used for? Its role is to turn the 8MHz clock frequency X4 into 32MHZ, remember that only 8MHZ can, other frequencies are not acceptable.
Set the clock frequency to 32 MHz using the internal clock
Development environment: MPLAB X IDE
Chip model: PICLF1823
#include
__CONFIG(FOSC_INTOSC&WDTE_OFF&PWRTE_ON&MCLRE_OFF&CP_ON&CPD_OFF&BOREN_ON
&CLKOUTEN_OFF&IESO_ON&FCMEN_ON);//This is going to the previous line.
__CONFIG(PLLEN_ON&LVP_OFF) ;//Set the FOSC: oscillator select bit to INTOSC, enable PLLEN
Void init_fosc(void)
{
OSCCON = 0xF0; // 32MHZ IRCF clock frequency selection bit set to 8MHZ, enable 4XPLL
}
Int main(int argc, char** argv) {
Init_fosc();
While(1);
}

P01 Series Push Wire Connectors

Push-in wire connector with good clamping force

For solid/stranded/tinned flexible wires

Transparent housing for visual inspection of connection

Interlock housing for orderly installation

Colour-coded for easy identification


BELEKS P01 Series Push Wire Connectors,Fast Connectors,quick Connector,push-in connectors,2.5 mm2 fast connectors

Jiangmen Krealux Electrical Appliances Co.,Ltd. , https://www.krealux-online.com