Ejemplo n.º 1
0
/*******************************************************************************
* Function Name: Timer_2_Start
********************************************************************************
*
* Summary:
*  The start function initializes the timer with the default values, the
*  enables the timerto begin counting.  It does not enable interrupts,
*  the EnableInt command should be called if interrupt generation is required.
*
* Parameters:
*  void
*
* Return:
*  void
*
* Global variables:
*  Timer_2_initVar: Is modified when this function is called for the
*   first time. Is used to ensure that initialization happens only once.
*
*******************************************************************************/
void Timer_2_Start(void) 
{
    if(Timer_2_initVar == 0u)
    {
        Timer_2_Init();

        Timer_2_initVar = 1u;   /* Clear this bit for Initialization */
    }

    /* Enable the Timer */
    Timer_2_Enable();
}
Ejemplo n.º 2
0
/****************************************************************************
 *
 *  NAME        : A2D_Init
 *
 *  DESCRIPTION : 
 *
 ****************************************************************************/
void A2D_Init (void)
{
// define all the analog inputs as singled-ended inputs
// ---------------------------------------------------- 
	AMX0CF = 0;

// define the conversion clock period and the the intenal amplifier gain
// SAR conversion clock = 8 system clocks, gain = 1
// ------------------------------------------------
	ADC0CF = 0x38;  

// define the first input to be sampled and select it
// --------------------------------------------------  
	A2DCurrentAnalogPin  = CPU_ANALOG_IN_1;
	AMX0SL = SELECT_CPU_ANALOG_IN1;
 
// select internal refernce, enables the bias for the ADC, enable the temperature sensor
// -------------------------------------------------------------------------------------
	REF0CN = 0x07;

// zero the samples buffer
// -----------------------
	memset(A2DSamplesBuffer,0,NO_OF_CPU_ANALOG_INPUTS * sizeof(WORD));

// select the A2D for timer 2 overflow work mode
// ---------------------------------------------
	ADC0CN = 0x0c;
	
// init timer 2 to use timer 2 overflow for initiating an A2D sample
// -----------------------------------------------------------------
	Timer_2_Init();

// enable the A2D converter
// ------------------------
	ADC0CN |= A2D_ENABLE;
	EIE2 |= A2D_INT_ENABLE;

// enable interrputs
// -----------------
	EA |= ENABLE;


}//End of ADCInit