#use "default.h"

/*
	SC1INT0.C

	CM71xx/Z1 and CM72xx/Z2

   This sample program show the use of the /INT0 interrupt line.
	INT0 is set to receive one interrupt when /INT0 is low.
	Note that INT0 is level sensitive.
*/

void set_int0();
int int0data;
main()
{
	 int0data = 0x0000;
    set_int0();

    printf("Touch /INT0 to ground to generate one interrupt.\n");  
    while(1)
    {
    	  hitwd();
        runwatch();
		  if(int0data == 0x1234)
		  {
		  		int0data = 0x0000;
		  		printf("Received one INT0 interrupt !!!\n");
				printf("Execute function set_int0() from the watch\n");
				printf("window to reload INT0.\n");
		  }			
    }
}

// void set_int0()
// Enable INT0 interrupt.
void set_int0()
{
   DI();
   ISET(ITC, 0);        // enable INT0 interrupt
   EI();
}

#JUMP_VEC RST38_VEC int0test

interrupt reti int0test()
{
	 IRES(ITC, 0);			// turn off INT0 interrupt	
	 int0data = 0x1234;
}

