Chapter 4 Notes
Chapter 4 Notes
16CXXX/16FXXX 8 14-bit 35 1
PIC 18f has a RISC architecture that comes with some standard features such as
On chip program ROM, Data RAM, Data EEPROM, timers, ADC, serial port
(USART) and I/O ports, oscillator and CCP module. Size of memory and I/O
ports varies as per the family.
It consists of ALU, control unit, microprocessor unit and accumulator, etc. Arithmetic
logic unit is used for arithmetic operations and to take logical decisions. Memory is
used for storing the instructions after processing. To control the internal and external
peripherals, control unit is used which are connected to the CPU. The accumulator is
used for storing the results of arithmetic and logical instructions.
Memory Organization
Key Features:
CPU Operation: Halted or clock speed reduced.
Peripheral Clocks: Continue to run.
Wake-Up Sources: Various interrupts and WDT.
Watchdog Timer (WDT) Wake-Up
The WDT can be used to periodically wake up the microcontroller from Sleep Mode,
allowing the device to perform periodic tasks while conserving power.
Configuration:
Configure the WDT prescaler and enable the WDT.
Brown out Detect in PIC 18f series:-
The Brown-Out Reset (BOR) feature in PIC18F series microcontrollers is designed to protect
the system from unexpected behaviour due to low voltage conditions. When the supply
voltage drops below a certain threshold, the BOR circuit resets the microcontroller, ensuring
that it operates only when the voltage is within safe limits.
Key Features of Brown-Out Reset
1. Threshold Voltage: The BOR has a predefined threshold voltage. When the supply
voltage falls below this threshold, the BOR triggers a reset. Different PIC18F devices
might have different BOR threshold options.
2. BOR Control Register: The behavior of the BOR can be controlled via configuration
bits and specific registers. For example, some devices use the BORCON register to
control BOR settings.
3. BOR Enable/Disable: The BOR can be enabled or disabled through configuration
bits in the configuration registers.
4. Software Control: On some devices, the BOR can be controlled through software,
allowing the user to enable or disable it during runtime.
Configuration Bits
The configuration of the BOR is typically set using configuration bits in the CONFIG registers.
Key Registers and Bits
1. BORCON Register (if available in your specific PIC18F device):
o BOREN: Enable/disable BOR.
o BORFS: Fast Start-up mode (if available).
2. RCON Register:
o RCONbits.BOR: This bit is set when a Brown-Out Reset occurs. It can be cleared by
software.
Summary
The Brown-Out Reset feature in PIC18F series microcontrollers is a crucial safeguard against
low voltage conditions that could lead to unpredictable behaviour. By properly configuring
and utilizing the BOR feature, you can enhance the reliability and stability of your
applications, ensuring that the microcontroller operates only within safe voltage levels.
A watchdog timer (WDT) is a hardware timer used to detect and recover from malfunctions
in embedded systems. This RC oscillator used in WDT is separate from the RC oscillator of
the OSC1/CLKI pin.
Even if the clock on the OSC1/CLKI and OSC2/CLKO/ RA6 pins of the device has been
stopped, WDT will run.
• Resetting the microcontroller: If the WDT detects a software malfunction, it resets the
device.
• Waking the device from sleep mode: The WDT can wake the device from sleep or
idle mode. This is known as a WDT wake-up.
• Resetting during unexpected execution: The WDT's window mode can reset the
device if a critical part of the code executes too quickly or too slowly.
2. Prescaler Settings:
o The WDT in PIC18F series has a prescaler to extend the timeout period. This prescaler is
controlled through software.
4. Configuration Bits:
o Set the WDTEN bit in the CONFIG2H register or SWDTEN bit in WDTCON register to
enable the WDT.
o Choose the appropriate prescaler value by setting the WDTPS bits in the CONFIG2H
register.
6. Prescaler Setting:
o The WDT prescaler determines the timeout period of the WDT. The default prescaler
values can vary based on the microcontroller.
7. Timeout Period:
o The timeout period is calculated based on the prescaler value and the WDT oscillator
frequency. Ensure the timeout period is long enough to accommodate the longest
execution path of your code.
o If your application uses sleep mode, the WDT can be used to wake up the
microcontroller from sleep.