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


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

  /** Voltage reference for external & internal */
  vfnVREF_Init(2);
  
  /** Configure DAC */
  TPM1SC = 0x4A;
  vfnDACSetPointer(0,15);
  vfnDAC_Init(gu8DACConfig1, gu8DACConfig2);
 // vfnDACFillBuffer(&au16WaveForm[0]); 
   
  /** Configure ADC */
  vfnADC_Init ();
  vfnADConfigChannel(1);
  ADC_CONVERT_CONTINUOUS_CHANNEL(1); 
  
  

  for(;;) 
  {
	if (ADC_COCO)
	{
		ADC_COCO_CLEAR;
		vfnGraphicWords(&sADC.gu16LatestResult[0]);
	}
	
  __RESET_WATCHDOG();	
  } 
}

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