8.8.1 di Macro

A macro that disables interrupts.

Include

<xc.h>

Prototype

void di(void);

Remarks

This macro inserts a cli instruction, which disables global interrupts.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

unsigned int read_timer1(void)
{
  unsigned int val;

  di();                // disable interrupts
  val = TCNT1;         // read timer value register; TEMP used internally
  ei();                // re-enable interrupts
  return val;
}