//************************************************************
//---------------XiAn AnaDig IC Inc.(XAD-IC)------------------
//-----------------C File Standard--------------------
//************************************************************
//#Author      : Xuhh
//#Case name   : flash
//#Function    :
//DAC0与DAC1电压值通过FVR PA1每5S间隔交换输出  RX0_PIN TRISB1    TX0_PIN TRISB2  9600
//************************************************************
#include "AD18F06A.h"
#include "stdio.h"
#include "periph.h"
#include "usart.h"

__CONFIG(1,_FINTOSC_DIV1_1L   & _LVREN_ON_1L       & _LVR24V_1L                                                                                          );
__CONFIG(2,_FLASH_CP7_OFF_2L  & _FLASH_CP6_OFF_2L  & _FLASH_CP5_OFF_2L   & _FLASH_CP4_OFF_2L   & _FLASH_CP3_OFF_2L
         & _FLASH_CP2_OFF_2L  & _FLASH_CP1_OFF_2L  & _FLASH_CP0_OFF_2L   & _CRYLEN_OFF_2L      & _CRYHEN_OFF_2L
  	     & _IDIS_ON_2L        & _CKSUM_OFF_2L      & _CBP_OFF_2L         & _RESETE_OFF_2L      & _RSEL_LOW_2L     & _STV_ON_2L              	         );
__CONFIG(3,_DBG_OFF_3L        & _PSUT_8_3L         & _FCPU_2T_3L         & _WDTEN_OFF_3L       & _TWDT_111_3L                                            );
__CONFIG(4,_OSCM_HIRC_16M_4L  &_ENVDDL_ON_4L      & _EEDIS_OFF_4L       & _FLDIS_OFF_4L       & _FCMEN_OFF_4L    & _IESO_OFF_4L&  _DBGS_IOSEL_1_4L      );


//DAC0与DAC1电压值通过FVR PA1每5S间隔交换输出，
void main(void)
{

	//GPIO输出初始化
    GPIO_OUT_Init();
   	usart0_init();			//RX0_PIN TRISB1    TX0_PIN TRISB2
	printf("DAC_TEST...\r\n\r\n");
    DAC0_init();
    DAC1_init();
    FVR_init();
    while(1)
	{
		FVRCON0 = 0x63;     //DAC0_OUT
        __delay_ms(5000);
        FVRCON0 = 0x64;     //DAC1_OUT
        __delay_ms(5000);
	}
}



