#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "MCG.h"
#include "ADC.h"
#include "DAC.h"


void main(void) 
{
  EnableInterrupts;
	
  vfnMCG_Init();

	/**Step2: Configure sine wave */
	TPM1SC = 0x4A;
	vfnDACV1SetPointer(0,15); 
	vfnDACV1Initialization(gu8DACConfig1, gu8DACConfig2);
	vfnDACFillBuffer((UINT16 *)&au16WaveForm[0],(sizeof(au16WaveForm) >> 1));

  for(;;) 
  {
	  if (DAC_NEW_DATA)
	  {
		  DAC_NEW_DATA_CLEAR; 
	  }
	  __RESET_WATCHDOG();	/* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}

__interrupt VectorNumber_Vtpm1ovf void TPM1_ISR (void)
{
    (void)TPM1SC;
    TPM1SC_TOF = 0;
    DACV1_NEW_DATA;
    DACV1_TRIGGER; 
}
