0% found this document useful (0 votes)
7 views

Chapter 4 Notes

Uploaded by

annexshaw26
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 4 Notes

Uploaded by

annexshaw26
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 4 notes

Stack Instruction Number of Interrupt


IC family size word size instructions vectors

12CXXX/12FXXX 2 12- or 14-bit 33 None

16C5XX/16F5XX 2 12-bit 33 None

16CXXX/16FXXX 8 14-bit 35 1

58, including hardware


17CXXX 16 16-bit multiply 4

75, including hardware


18CXXX/18FXXX 32 16-bit multiply 2
Comparison of features of different PIC series:-
Simplified architecture of PIC18f series:-

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.

CPU (Central Processing Unit)

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

The memory module in the PIC microcontroller architecture consists of RAM


(Random Access Memory), ROM (Read Only Memory), EEPROM (Electrically
Erasable programmable Read Only Memory) and STACK.
Power down modes inPIC18f series
The PIC18F series microcontrollers provide various power-down modes to conserve energy
when the device is not performing critical tasks.
Sleep Mode
Sleep Mode is the primary power-down mode in the PIC18F series microcontrollers. When
the device enters Sleep Mode, the CPU stops executing instructions, and the main oscillator is
turned off. However, some peripherals can remain active depending on their clock source and
configuration.
Key Features:
 CPU Operation: Stops.
 Oscillators: Main oscillator is turned off, but secondary oscillators (e.g., Timer1
oscillator) can continue to operate.
 Peripherals: Peripherals that use secondary oscillators can remain active.
 Wake-Up Sources: Various sources can wake the microcontroller from Sleep Mode
o External interrupts.
o Timer interrupts (e.g., Timer1 with an external oscillator).
o Watchdog Timer (WDT).
o Brown-out Reset (BOR).
Entering Sleep Mode:
The SLEEP() instruction is used to enter Sleep Mode.
Doze Mode
Doze Mode allows the CPU clock to be reduced while the peripheral clocks continue to run at
full speed. This mode is useful for applications where the CPU does not need to run at full
speed, but peripheral operations must continue.
Key Features:
 CPU Clock: Reduced.
 Peripheral Clocks: Continue to run at full speed.
 Clock Reduction Ratio: Configurable.
Configuration:
Doze Mode is configured using the OSCCON register.
Idle Mode
Although the PIC18F series microcontrollers do not have a built-in Idle Mode like some other
microcontroller families, a similar effect can be achieved by reducing the CPU clock speed or
by putting the CPU to sleep while allowing peripherals to continue operating.

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.

V1 is the normal power supply voltage.


V2 is the point where the microcontroller may not operate reliably.
V3 is the point where operation stops entirely.
Watchdog timer:-

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.

Uses of watchdog timer (WDT) in a PIC microcontroller

• 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.

1. Enable Watchdog Timer:


o The WDT can be enabled by controlling WDTEN bit in the configuration registers
(CONFIG2H).

2. Prescaler Settings:
o The WDT in PIC18F series has a prescaler to extend the timeout period. This prescaler is
controlled through software.

3. Clearing the Watchdog Timer:


o To prevent the WDT from resetting the microcontroller, it must be cleared
periodically. This is done using the CLRWDT instruction.

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.

5. Clearing the WDT:


o Use the CLRWDT instruction in used to clear the WDT and prevent it from resetting
the microcontroller.

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.

8. Using Sleep Mode:

o If your application uses sleep mode, the WDT can be used to wake up the
microcontroller from sleep.

You might also like