Выбрать главу
CONFIG1H

The CONFIG1H configuration register is at address 300001H and is used to select the microcontroller clock sources. The bit patterns are shown in Figure 2.6.

Figure 2.6: CONFIG1H register bits 

CONFIG2L

The CONFIG2L configuration register is at address 300002H and is used to select the brown-out voltage bits. The bit patterns are shown in Figure 2.7.

Figure 2.7: CONFIG2L register bits

CONFIG2H

The CONFIG2H configuration register is at address 300003H and is used to select the watchdog operations. The bit patterns are shown in Figure 2.8.

Figure 2.8: CONFIG2H register bits

2.1.4 The Power Supply

The power supply requirements of the PIC18F452 microcontroller are shown in Figure 2.9. As shown in Figure 2.10, PIC18F452 can operate with a supply voltage of 4.2V to 5.5V at the full speed of 40MHz. The lower power version, PIC18LF452, can operate from 2.0 to 5.5 volts. At lower voltages the maximum clock frequency is 4MHz, which rises to 40MHz at 4.2V. The RAM data retention voltage is specified as 1.5V and will be lost if the power supply voltage is lowered below this value. In practice, most microcontroller-based systems are operated with a single +5V supply derived from a suitable voltage regulator.

Figure 2.9: The PIC8F452 power supply parameters

Figure 2.10: Operation of PIC18LF452 at different voltages

2.1.5 The Reset

The reset action puts the microcontroller into a known state. Resetting a PIC18F microcontroller starts execution of the program from address 0000H of the program memory. The microcontroller can be reset during one of the following operations:

• Power-on reset (POR)

• MCLR reset

• Watchdog timer (WDT) reset

• Brown-out reset (BOR)

• Reset instruction

• Stack full reset

• Stack underflow reset

Two types of resets are commonly used: power-on reset and external reset using the MCLR pin.

Power-on Reset

The power-on reset is generated automatically when power supply voltage is applied to the chip. The MCLR pin should be tied to the supply voltage directly or, preferably, through a 10K resistor. Figure 2.11 shows a typical reset circuit.

Figure 2.11: Typical reset circuit

For applications where the rise time of the voltage is slow, it is recommended to use a diode, a capacitor, and a series resistor as shown in Figure 2.12.

Figure 2.12: Reset circuit for slow-rising voltages

In some applications the microcontroller may have to be reset externally by pressing a button. Figure 2.13 shows the circuit that can be used to reset the microcontroller externally. Normally the MCLR input is at logic 1. When the RESET button is pressed, this pin goes to logic 0 and resets the microcontroller.

Figure 2.13: External reset circuit

2.1.6 The Clock Sources

The PIC18F452 microcontroller can be operated from an external crystal or ceramic resonator connected to the microcontroller’s OSC1 and OSC2 pins. In addition, an external resistor and capacitor, an external clock source, and in some models internal oscillators can be used to provide clock pulses to the microcontroller. There are eight clock sources on the PIC18F452 microcontroller, selected by the configuration register CONFIG1H. These are:

• Low-power crystal (LP)

• Crystal or ceramic resonator (XT)

• High-speed crystal or ceramic resonator (HS)

• High-speed crystal or ceramic resonator with PLL (HSPLL)

• External clock with FOSC/4 on OSC2 (EC)

• External clock with I/O on OSC2 (port RA6) (ECIO)

• External resistor/capacitor with FOSC/4 output on OSC2 (RC)

• External resistor/capacitor with I/O on OSC2 (port RA6) (RCIO)

Crystal or Ceramic Resonator Operation

The first several clock sources listed use an external crystal or ceramic resonator that is connected to the OSC1 and OSC2 pins. For applications where accuracy of timing is important, a crystal should be used. And if a crystal is used, a parallel resonant crystal must be chosen, since series resonant crystals do not oscillate when the system is first powered.

Figure 2.14 shows how a crystal is connected to the microcontroller. The capacitor values depend on the mode of the crystal and the selected frequency. Table 2.4 gives the recommended values. For example, for a 4MHz crystal frequency, use 15pF capacitors. Higher capacitance increases the oscillator stability but also increases the start-up time.

Figure 2.14: Using a crystal as the clock input

Table 2.4: Capacitor values

Mode Frequency C1,C2 (pF)
LP 32 KHz 33
200 KHz 15
XT 200 KHz 22–68
1.0 MHz 15
4.0 MHz 15
HS 4.0 MHz 15
8.0 MHz 15–33
20.0 MHz 15–33
25.0 MHz 15–33

Resonators should be used in low-cost applications where high accuracy in timing is not required. Figure 2.15 shows how a resonator is connected to the microcontroller.

Figure 2.15: Using a resonator as the clock input

The LP (low-power) oscillator mode is advised in applications to up to 200KHz clock. The XT mode is advised to up to 4MHz, and the HS (high-speed) mode is advised in applications where the clock frequency is between 4MHz to 25MHz.

An external clock source may also be connected to the OSC1 pin in the LP, XT, or HS modes as shown in Figure 2.16.

Figure 2.16: Connecting an external clock in LP, XT, or HS modes

External Clock Operation

An external clock source can be connected to the OSC1 input of the microcontroller in EC and ECIO modes. No oscillator start-up time is required after a power-on reset. Figure 2.17 shows the operation with the external clock in EC mode. Timing pulses at the frequency FOSC/4 are available on the OSC2 pin. These pulses can be used for test purposes or to provide pulses to external devices.