Microchip Technology SW006021-1N 사용자 설명서
Library Functions
2012 Microchip Technology Inc.
DS52053B-page 329
DEVICE_ID_READ()
Synopsis
#include <xc.h>
unsigned int device_id_read(void);
Description
This function returns the device ID code that is factory-programmed into the chip. This
code can be used to identify the device and its revision number.
code can be used to identify the device and its revision number.
Example
#include <xc.h>
void
main (void)
{
unsigned int id_value;
unsigned int device_code;
unsigned char revision_no;
id_value = device_id_read();
/* lower 5 bits represent revision number
* upper 11 bits identify device */
device_code = (id_value >> 5);
revision_no = (unsigned char)(id_value & 0x1F);
}
See Also
flash_read()
, config_read()
Return Value
device_id_read()
returns the 16-Bit factory-programmed device id code used to
identify the device type and its revision number.
Note
The
device_id_read()
is applicable only to those devices which are capable of
reading their own program memory.
DI, EI
Synopsis
#include <xc.h>
void ei (void)
void di (void)
Description
The
di()
and
ei()
routines disable and re-enable interrupts respectively. These are
implemented as macros. 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.
possible to return an incorrect value, if the interrupt occurred between accesses to
successive words of the count value.
The ei() macro should never be called in an interrupt function, and there is no need
to call di() in an interrupt function.
to call di() in an interrupt function.