SW500010 Microchip Technology, SW500010 Datasheet - Page 218

HI-TECH C PRO FOR PIC10/12/16

SW500010

Manufacturer Part Number
SW500010
Description
HI-TECH C PRO FOR PIC10/12/16
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC10/12/16r
Datasheets

Specifications of SW500010

Supported Families
PIC10, PIC12, PIC16
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC10/12/16
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC10, PIC12, PIC14, PIC16, PIC16E
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
019P
778-1006
778-1006
DI, EI
Synopsis
Description
The di() and ei() routines disable and re-enable interrupts respectively. These are implemented as
macros defined in PIC.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
218
#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 SW500010