Example #1
0
  _IOPUWR = 0;
  _EXTR = 0;
  _WDTO = 0;
  _SLEEP = 0;
  _IDLE = 0;
  _BOR = 0;
  _POR = 0;
  _SWR = 0;

  *CXINTF_ptr = 0;
}


void DoCanInterrupt(void);

void __attribute__((interrupt(__save__(CORCON,SR)), no_auto_psv)) _C1Interrupt(void) {
  _C1IF = 0;
  DoCanInterrupt();
}

void __attribute__((interrupt(__save__(CORCON,SR)), no_auto_psv)) _C2Interrupt(void) {
  _C2IF = 0;
  DoCanInterrupt();
}

void DoCanInterrupt(void) {
  ETMCanMessage can_message;

  etm_can_slave_debug_data.CXINTF_max |= *CXINTF_ptr;
  
  if (*CXRX0CON_ptr & BUFFER_FULL_BIT) {
Example #2
0
#include <stdio.h>
#include <xc.h>

volatile bool interrupted = false;
volatile int preserved_variable = 1234;
volatile char nonpreserved_variable = 'A';

extern "C" void __attribute__((__interrupt__, __auto_psv__, __shadow__, __save__((preserved_variable)))) _T1Interrupt(void)
{
	IFS0bits.T1IF = 0;
	preserved_variable = 5678;
	nonpreserved_variable = 'B';
	interrupted = true;
}

int main (int argc, char *argv[])
{
	TMR1 = 0;
	T1CONbits.TON = 1;
	IFS0bits.T1IF = 0;
	IEC0bits.T1IE = 1;

	while (!interrupted);

	printf("%d %c\n", preserved_variable, nonpreserved_variable);

	return 0;
}