SW500008 Microchip Technology, SW500008 Datasheet - Page 206

PICC-18 STD

SW500008

Manufacturer Part Number
SW500008
Description
PICC-18 STD
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500008

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Standard
Kit Contents
Software And Docs
Mcu Supported Families
PIC18
Tool Function
Compiler
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
PIC18 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
015
778-1001
778-1001
DI, EI
Synopsis
Description
The di() macro disables all interrupts globally (regardless of priority settings), ei() re-enables inter-
rupts globally. These are implemented as macros defined in PIC18.h. The example shows the use
of ei() and di() around access to a long variable that is modified during an interrupt. If this was not
done, it would be possible to return an incorrect value, if the interrupt occurred between accesses to
successive words of the count value.
Example
192
#include <htc.h>
void ei (void)
void di (void)
#include <htc.h>
long count;
void
interrupt tick (void)
{
}
long
getticks (void)
{
count++;
long val;
di();
val = count;
ei();
return val;
/* Disable interrupts around access
to count, to ensure consistency.*/
Library Functions

Related parts for SW500008