#include "OB6710.h"
#include "ACMP2.h"

extern bit g_Acmp2Interrupt;
extern void ACMP2_Test_Interrupt(void);

#define PGA_GAIN_10X  0x02
#define PGA_GAIN_20X  0x00
#define PGA_ENABLE 0x01 
#define PGA_OUT           0x08
#define PGA_OUT_FILTER    0x0C

#define PGA_CURRENT_0UA   0x00
#define PGA_CURRENT_16UA  0x20
#define PGA_CURRENT_30UA0 0x30
#define PGA_BY_PASS 0x40

unsigned char Loop, Buff, P_Channel, N_Channel, Debounce;

void main(void)
{
	ACMP2_Test_Interrupt();
}

void ACMP2_Test_Interrupt(void)
{
	P2BUFFEN = 0x38;
	P2M0 = 0x00;
	P2M1 = 0x38;		
	OPACON = PGA_GAIN_10X | PGA_ENABLE | PGA_OUT  ;
  DACVAL0 = 125; // voltage = 2V
	DACCON = DACCON | 0x01;	
	ACMP2_Open(0, 0);	
	IEN1 = IEN1 | 0x08;
	EA = 1;	
	ACMP2_DebounceCount(100);
	while(1)
	{
		if(g_Acmp2Interrupt != 0x00)		
		{	
			P2_7 = ~P2_7;
		  g_Acmp2Interrupt = 0;
		}
	}
}