#include "OB39A16M2.h"
#include "ACMP.h"

extern bit g_Acmp1Interrupt;

void main(void)
{

  //----------P0.1/P0.3 is input Only--------
	P0M0 = P0M0 & 0xF5;
	P0M1 = P0M1 | 0x0A;
	ACMP1_Open(d_ACMP1_P_CHANNEL_1,  d_HYS_RANGE_30);
	ACMP1_EnableIE(d_ACMP1_IE_TYPE_BOTH);
	
	P3M0 = P0M0 &0xFC;
	P3M1 = P3M1 &0xFC;
	
	while(1)
	{
		P3_0 = ACMP1_OutputStatus();
	  if(g_Acmp1Interrupt == 1)
		{
			P3_1 = ~P3_1;
			g_Acmp1Interrupt = 0;
		}
	}
}