コード例 #1
0
ファイル: rmb20d01.c プロジェクト: EranSegal/ek-lm4f230H5QR
void RMBD01Init( void )
{

  //
  // Configure the ADC for Pitch and Roll
  // sequence 3 means a single sample
  // sequence 1, 2 means up to 4 samples
  // sequence 0 means up to 8 samples
  // we use sequence 1
  //
  if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0))
  {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples

    //
    // Select the external reference for greatest accuracy.
    //
    ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ENCODER_CHANNEL_PITCH);     // sample pitch
    ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END);     // sample roll
    ADCIntRegister(ADC0_BASE,1,ADCIntHandler);
    ADCSequenceEnable(ADC0_BASE, 1);
    ADCIntEnable(ADC0_BASE, 1);


    //
    // Setup timer for ADC_TRIGGER_TIMER
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	
    //
    // Configure the second timer to generate triggers to the ADC 
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
    TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet() / 1000); // 2 ms
  
    TimerControlStall(TIMER1_BASE, TIMER_A, true);
    TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

    //
    // Enable the timers.
    //	
    TimerEnable(TIMER1_BASE, TIMER_A);
    new_adc = false;
    //
  }
  //
  // Clear outstanding ADC interrupt and enable
  //
  ADCIntClear(ADC0_BASE, 1);
  IntEnable(INT_ADC0);
} // InitADC
コード例 #2
0
ファイル: ADC.c プロジェクト: tach4455/EE345M
int ADC_Collect(unsigned int channelNum, unsigned int fs, 
  unsigned long buffer[], unsigned int numberOfSamples){

  int i;
  unsigned long config;

  // Setting global pointer to point at array passed by funciton
  Buffer = buffer;

  // Determine input channel
  switch(channelNum){
    case 0: config = ADC_CTL_CH0; break;
	case 1: config = ADC_CTL_CH1; break;
	case 2: config = ADC_CTL_CH2; break;
	case 3: config = ADC_CTL_CH3; break;
  }

  // Enable the ADC0 for interrupt Sequence 0 with lower priority then single shot
  ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 1);

  // Configuring steps of sequence, last step contains ADC_CTL_END and ADC_CTL_IE config paramter
  for(i = 0; i < (numberOfSamples - 1); i++){
    ADCSequenceStepConfigure(ADC0_BASE, 0, i, config);
  }
  ADCSequenceStepConfigure(ADC0_BASE, 0, numberOfSamples - 1, config | ADC_CTL_END | ADC_CTL_IE);
  ADCIntRegister(ADC0_BASE, 0, ADC0_Handler);
  ADCSequenceEnable(ADC0_BASE, 0);

  // Disabling Timer0A for configuration
  TimerDisable(TIMER0_BASE, TIMER_A);

  // Configure as 16 bit timer and trigger ADC conversion
  TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC);
  TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

  //
  //
  // TODO: configure this to calculate load value based on frequency inputed
  //
  //
  TimerLoadSet(TIMER0_BASE, TIMER_A, 1000);
  TimerEnable(TIMER0_BASE, TIMER_A);

  ADCIntClear(ADC0_BASE, 0);
  TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

  ADCIntEnable(ADC0_BASE, 0);
  TimerIntEnable(TIMER0_BASE, TIMER_A);

  // Claering Status flag
  Status = FALSE;
  
  return 1; 
}
コード例 #3
0
ファイル: touch.c プロジェクト: Rommelius/ENB350-Assignment1
//*****************************************************************************
//
//! Initializes the touch screen driver.
//!
//! \param ui32SysClock is the frequency of the system clock.
//!
//! This function initializes the touch screen driver, beginning the process of
//! reading from the touch screen.  This driver uses the following hardware
//! resources:
//!
//! - ADC 0 sample sequence 3
//! - Timer 5 subtimer B
//!
//! \return None.
//
//*****************************************************************************
void
TouchScreenInit(uint32_t ui32SysClock)
{
    //
    // Set the initial state of the touch screen driver's state machine.
    //
    g_ui32TSState = TS_STATE_INIT;

    //
    // There is no touch screen handler initially.
    //
    g_pfnTSHandler = 0;

    //
    // Enable the peripherals used by the touch screen interface.
    //
   SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
   SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5);

    //
    // Configure the ADC sample sequence used to read the touch screen reading.
    //
   ADCHardwareOversampleConfigure(ADC0_BASE, 4);
   ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
   ADCSequenceStepConfigure(ADC0_BASE, 3, 0,
                                 TS_YP_ADC | ADC_CTL_END | ADC_CTL_IE);
   ADCSequenceEnable(ADC0_BASE, 3);

    //
    // Enable the ADC sample sequence interrupt.
    //
   ADCIntEnable(ADC0_BASE, 3);
   IntEnable(INT_ADC0SS3);

    //
    // Configure the timer to trigger the sampling of the touch screen
    // every 2.5 milliseconds.
    //
    if((HWREG(TIMER5_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0)
    {
       TimerConfigure(TIMER5_BASE, (TIMER_CFG_SPLIT_PAIR |
                                         TIMER_CFG_A_PWM |
                                         TIMER_CFG_B_PERIODIC));
    }
   TimerPrescaleSet(TIMER5_BASE, TIMER_B, 255);
   TimerLoadSet(TIMER5_BASE, TIMER_B, ((ui32SysClock / 256) / 400) - 1);
    TimerControlTrigger(TIMER5_BASE, TIMER_B, true);

    //
    // Enable the timer.  At this point, the touch screen state machine will
    // sample and run every 2.5 ms.
    //
   TimerEnable(TIMER5_BASE, TIMER_B);
}
コード例 #4
0
ファイル: main.c プロジェクト: FTGStudio/Sound-Visualizer
void InitializeTimers()
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);				 //Enable Timer0 peripheral
	TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);			 //Configure Timer0: 32-bit periodic mode for ADC Timer Trigger
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/16000);	 //16MHz interrupt
	TimerControlTrigger(TIMER0_BASE, TIMER_A, true); 			 //Configure Timer0 to generate trigger event for ADC
	TimerEnable(TIMER0_BASE, TIMER_A);							 //Enable Timer0


	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);				//Enable Timer1 peripheral (in case we need a delay)
	TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);			//Configure Timer1: 32-bit periodic mode
	TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet());	    //1 second interrupt
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);			//Enable Timer1 Interrupt
	TimerEnable(TIMER1_BASE, TIMER_A);							//Enable Timer1
}
コード例 #5
0
/*
 * function: InitSamplingTimer
 * return: none
 * */
void InitSamplingTimer() {
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
	TimerLoadSet(TIMER0_BASE, TIMER_A, LoadTimer);
	/*
	 * timer set : 20 (us)
	 * */
// Enable the sampling interrupt
	IntEnable(INT_TIMER0A);
// When timer hits zero, call interrupt
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
// Start the sampling timer
	TimerEnable(TIMER0_BASE, TIMER_A);
}
コード例 #6
0
ファイル: ADC.c プロジェクト: tach4455/EE345M
int ADC_Collect(unsigned int channelNum, unsigned int fs, 
  void (*task)(unsigned short)){

  unsigned long config;

  ADCTask = task;

  // Determine input channel
  switch(channelNum){
    case 0: config = ADC_CTL_CH0; break;
	case 1: config = ADC_CTL_CH1; break;
	case 2: config = ADC_CTL_CH2; break;
	case 3: config = ADC_CTL_CH3; break;
  }

  ADCSequenceDisable(ADC0_BASE, 0);

  // Enable the ADC0 for interrupt Sequence 0 with lower priority then single shot
  ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 1);

  // Configuring steps of sequence, last step contains ADC_CTL_END and ADC_CTL_IE config paramter
  config |= ADC_CTL_END | ADC_CTL_IE;
  ADCSequenceStepConfigure(ADC0_BASE, 0, 0, config);

  // Disabling Timer0A for configuration
  TimerDisable(TIMER0_BASE, TIMER_A);

  // Configure as 16 bit timer and trigger ADC conversion
  TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

  TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/ fs);
  TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

  ADCSequenceOverflowClear(ADC0_BASE, 0);
  ADCSequenceUnderflowClear(ADC0_BASE, 0);
  ADCIntClear(ADC0_BASE, 0);
  ADCSequenceEnable(ADC0_BASE, 0);
 
  TimerEnable(TIMER0_BASE, TIMER_A);
  TimerIntEnable(TIMER0_BASE, TIMER_A);
  ADCIntEnable(ADC0_BASE, 0);

  IntEnable(INT_ADC0SS0);
  
  return 1; 
}
コード例 #7
0
void Timer1_Init(unsigned int frequency)
{
	uint32_t ui32Period; //desired clock period

	// before calling any peripheral specific driverLib function we must enable the clock to that peripheral!!!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

	/*
	 * Timer 1 as a 32-bit timer in periodic mode.
	 * TIMER1_BASE is the start of the timer registers for Timer0 in the peripheral section of the memory map.
	 */
	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);

	/*
	 * desired frequency = x Hz
	 * duty cycle = 50% (interrupt at 1/2 of the desired period)
	 */
	ui32Period = (SysCtlClockGet() / frequency) / 2;

	/*
	 * load calculated period into the Timer’s Interval Load register using the TimerLoadSet
	 * you have to subtract one from the timer period since the interrupt fires at the zero count
	 */
	TimerLoadSet(TIMER1_BASE, TIMER_A, ui32Period -1);

	// Enable triggering
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);


	/*** INTERRUPT ENABLE ***/

	IntEnable(INT_TIMER1A); // enables the specific vector associated with Timer0A
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); //enables a specific event within the timer to generate an interrupt.(timeout of Timer 0A)
//	IntMasterEnable(); //master interrupt enable API for all interrupts.

	/* TIMER ENABLE */
	TimerEnable(TIMER1_BASE, TIMER_A);

}
コード例 #8
0
ファイル: adc.c プロジェクト: joshthornton/ENGG4810
void adc_init(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);

	//Set what the timer runs to
	TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() / FREQ );

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS);

	ADCSequenceDisable(ADC0_BASE, 1);
	ADCSequenceConfigure(ADC_BASE, 1, ADC_TRIGGER_TIMER, 0);

	ADCSequenceStepConfigure(ADC_BASE, 1, 0, ADC_CTL_CH0);
	ADCSequenceStepConfigure(ADC_BASE, 1, 1, ADC_CTL_CH1);
	ADCSequenceStepConfigure(ADC_BASE, 1, 2, ADC_CTL_CH2);
	ADCSequenceStepConfigure(ADC_BASE, 1, 3, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);

	ADCSequenceEnable(ADC0_BASE, 1);
	ADCIntEnable(ADC0_BASE, 1);

	TimerEnable(TIMER1_BASE, TIMER_A);

	//Set timer 1A to trigger the ADC
	TimerControlTrigger(TIMER1_BASE, TIMER_A, 1);

	//May be useful:
	//SysCtlADCSpeedGet();

	ADCIntClear(ADC0_BASE, 1);
	ADCIntEnable(ADC0_BASE, 1);
	IntEnable(INT_ADC0SS1);
}
コード例 #9
0
ファイル: main.c プロジェクト: joseayebenes/TivaFly
void confTimer(){

	//Inicializamos el TIMER2 para el ADC como Trigger a una frecuencia de 10Hz
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER2);
	TimerControlStall(TIMER2_BASE,TIMER_A,true);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);
	uint32_t ui32Period = SysCtlClockGet() *0.1;
	TimerLoadSet(TIMER2_BASE, TIMER_A, ui32Period -1);
	TimerControlTrigger(TIMER2_BASE,TIMER_A,true);
	TimerEnable(TIMER2_BASE, TIMER_A);

	//Inicializamos el TIMER4 para la pulsación larga con un periodo de 2 segundos
  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4);
  SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER4);
  TimerConfigure(TIMER4_BASE, TIMER_CFG_ONE_SHOT);
  ui32Period = (SysCtlClockGet() *2) ;
  TimerLoadSet(TIMER4_BASE, TIMER_A, ui32Period -1);
  IntEnable(INT_TIMER4A);
  TimerIntRegister(TIMER4_BASE,TIMER_A,timerBotonHandler);
  IntPrioritySet(INT_TIMER4A,5<<5);
  TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT);

}
コード例 #10
0
ファイル: os.c プロジェクト: AustinBlackstone/EE345M-S2012
// ******** OS_Init ************
// initialize operating system, disable interrupts until OS_Launch
// initialize OS controlled I/O: serial, ADC, systick, select switch and timer2 
// input:  none
// output: none
void OS_Init(void){
	DisableInterrupts();
	RUNPT=0;

// Enable processor interrupts.
    //
    //IntMasterEnable();
	TIMELORD=0; //initialize the system counter for use with thingies (no shit)
    SDEBOUNCEPREV = 0;
    btndown_time = 0;
    
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);	//Init System Clock

	//Systick Init (Thread Scheduler)
	//taken care of in OS_Launch
     
	// Timers galore!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC));
	TimerControlTrigger(TIMER0_BASE, TIMER_A, true);  // TIMELORD Updater
	TimerControlTrigger(TIMER0_BASE, TIMER_B, true);  // ADC_Collect Timer
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/1000);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
	IntEnable(INT_TIMER0A);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);  // Periodic Timer 1
	TimerControlTrigger(TIMER1_BASE, TIMER_B, true);  // Periodic Timer 2
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER2_BASE, TIMER_A, true);  // Periodic Timer 3
	TimerControlTrigger(TIMER2_BASE, TIMER_B, true);  // Periodic Timer 4
	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT);
	
	// Init ADC Stuff
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);  
	  
	// Init Debugging LED
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);

	//Semaphores, OS Stuff
    OS_InitSemaphore(&oled_free,1);
	OS_InitSemaphore(&OSMailBoxSema4,0);
	OS_MailBox_Init();
	
	//UART & OLED 
	UARTInit();
	RIT128x96x4Init(1000000); //Init OLED
	//RIT128x96x4StringDraw("Hello World", 0, 12, 15);
	
	//ADC
    ADC_Init(); // Init ADC to run @ 1KHz
        
	//Eval Buttons
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
    GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_1);
    IntEnable(INT_GPIOE);  
    
  	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);
    IntEnable(INT_GPIOF);  
  
    /* This works for now, but Stellarisware Function owuld be nice */
    /*SYSCTL_RCGC2_R |= 0x00000020; // (a) activate port F
//	delay = SYSCTL_RCGC2_R;		    //delay, cause i said so
	GPIO_PORTF_DIR_R &= ~0x02;    // (c) make PF1 in
	GPIO_PORTF_DEN_R |= 0x02;     //     enable digital I/O on PF1
	GPIO_PORTF_IS_R &= ~0x02;     // (d) PF1 is edge-sensitive
	GPIO_PORTF_IBE_R &= ~0x02;    //     PF1 is not both edges
	GPIO_PORTF_IEV_R &= ~0x02;    //     PF1 falling edge event
	GPIO_PORTF_ICR_R = 0x02;      // (e) clear flag4
	GPIO_PORTF_IM_R |= 0x02;      // (f) arm interrupt on PF1
	NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|(0<<21); // (g) priority (shifted into place) (will get set in OS_AddButtonTask)
	NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC
	//dont enable interrupts 
	GPIO_PORTF_PUR_R |= 0x02;	    //add pull up resistor, just for shits and giggles
    */
}
コード例 #11
0
ファイル: touch.c プロジェクト: hitubaldaniya/lumweb
//*****************************************************************************
//
//! Initializes the touch screen driver.
//!
//! This function initializes the touch screen driver, beginning the process of
//! reading from the touch screen.  This driver uses the following hardware
//! resources:
//!
//! - ADC sample sequence 3
//! - Timer 1 subtimer A
//!
//! \return None.
//
//*****************************************************************************
void
TouchScreenInit(void)
{
    //
    // Set the initial state of the touch screen driver's state machine.
    //
    g_ulTSState = TS_STATE_INIT;

    //
    // Determine which calibration parameter set we will be using.
    //
    g_plParmSet = g_lTouchParameters[SET_NORMAL];

    //
    // There is no touch screen handler initially.
    //
    g_pfnTSHandler = 0;

    //
    // Enable the peripherals used by the touch screen interface.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(TS_P_PERIPH);
    SysCtlPeripheralEnable(TS_N_PERIPH);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

    //
    // Configure the ADC sample sequence used to read the touch screen reading.
    //
    ADCHardwareOversampleConfigure(ADC0_BASE, 4);
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0,
                             ADC_CTL_CH_YP | ADC_CTL_END | ADC_CTL_IE);
    ADCSequenceEnable(ADC0_BASE, 3);

    //
    // Enable the ADC sample sequence interrupt.
    //
    ADCIntEnable(ADC0_BASE, 3);
    IntEnable(INT_ADC3);

    //
    // Configure the GPIOs used to drive the touch screen layers.
    //
    GPIOPinTypeGPIOOutput(TS_P_BASE, TS_XP_PIN | TS_YP_PIN);

    //
    // If no daughter board is installed, set up GPIOs to drive the XN and YN
    // signals.
    //
    if(g_eDaughterType == DAUGHTER_NONE)
    {
        GPIOPinTypeGPIOOutput(TS_N_BASE, TS_XN_PIN | TS_YN_PIN);
    }

    GPIOPinWrite(TS_P_BASE, TS_XP_PIN | TS_YP_PIN, 0x00);
    if(g_eDaughterType == DAUGHTER_NONE)
    {
        GPIOPinWrite(TS_N_BASE, TS_XN_PIN | TS_YN_PIN, 0x00);
    }

    //
    // See if the ADC trigger timer has been configured, and configure it only
    // if it has not been configured yet.
    //
    if((HWREG(TIMER1_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0)
    {
        //
        // Configure the timer to trigger the sampling of the touch screen
        // every millisecond.
        //
        TimerConfigure(TIMER1_BASE, (TIMER_CFG_16_BIT_PAIR |
                                     TIMER_CFG_A_PERIODIC |
                                     TIMER_CFG_B_PERIODIC));
        TimerLoadSet(TIMER1_BASE, TIMER_A, (SysCtlClockGet() / 1000) - 1);
        TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

        //
        // Enable the timer.  At this point, the touch screen state machine
        // will sample and run once per millisecond.
        //
        TimerEnable(TIMER1_BASE, TIMER_A);
    }
}
コード例 #12
0
ファイル: os.c プロジェクト: AustinBlackstone/EE345M-S2012
// ******** OS_Init ************
// initialize operating system, disable interrupts until OS_Launch
// initialize OS controlled I/O: serial, ADC, systick, select switch and timer2 
// input:  none
// output: none
void OS_Init(void){
	DisableInterrupts();
	RUNPT=0;
	JitterInit();
	deleteme=0;

// Enable processor interrupts.
    //
    //IntMasterEnable();
	TIMELORD=0; //initialize the system counter for use with thingies (no shit)
	NUMBLOCKEDTHREADS=0;
	TOTALNUMTHREADS=0;
    SDEBOUNCEPREV = 0;
    btndown_time = 0;
    

	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);	//Init System Clock

	//Systick Init (Thread Scheduler)
	//taken care of in OS_Launch
     
	// Timers galore!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC));
	//TimerControlTrigger(TIMER0_BASE, TIMER_A, false);  // TIMELORD Updater
	//TimerControlTrigger(TIMER0_BASE, TIMER_B, true);  // ADC_Collect Timer
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/1000);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
	TimerEnable(TIMER0_BASE, TIMER_BOTH);
	IntEnable(INT_TIMER0A);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);  // Periodic Timer 1
	TimerControlTrigger(TIMER1_BASE, TIMER_B, true);  // Periodic Timer 2
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER2_BASE, TIMER_A, true);  // Periodic Timer 3
	TimerControlTrigger(TIMER2_BASE, TIMER_B, true);  // Periodic Timer 4
	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT);
	
	// Init ADC Stuff
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);  
	  
	// Init Debugging LED
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);

	//Semaphores, OS Stuff
    OS_InitSemaphore(&oled_free,1);
	OS_InitSemaphore(&OSMailBoxSema4,0);
	OS_MailBox_Init();
	
	//UART & OLED 
	UARTInit();
	RIT128x96x4Init(1000000); //Init OLED
	//RIT128x96x4StringDraw("Hello World", 0, 12, 15);
	
	//ADC
    ADC_Init(); // Init ADC to run @ 1KHz

	//Select Switch (button press) Init	(select switch is PF1) (pulled from page 67 of the book and modified for PF1...i think)
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
  /*GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
  IntEnable(INT_GPIOF);  
  //IntPrioritySet(INT_GPIOF, 0x00);
  GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_BOTH_EDGES);
  GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);*/
  //NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC (Not sure what Stellarisware function replaces this)
  
  
  /* This works for now, but Stellarisware Function owuld be nice */
  SYSCTL_RCGC2_R |= 0x00000020; // (a) activate port F
//	delay = SYSCTL_RCGC2_R;		    //delay, cause i said so
	GPIO_PORTF_DIR_R &= ~0x02;    // (c) make PF1 in
	GPIO_PORTF_DEN_R |= 0x02;     //     enable digital I/O on PF1
	GPIO_PORTF_IS_R &= ~0x02;     // (d) PF1 is edge-sensitive
	GPIO_PORTF_IBE_R &= ~0x02;    //     PF1 is not both edges
	GPIO_PORTF_IEV_R &= ~0x02;    //     PF1 falling edge event
	GPIO_PORTF_ICR_R = 0x02;      // (e) clear flag4
	GPIO_PORTF_IM_R |= 0x02;      // (f) arm interrupt on PF1
	NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|(0<<21); // (g) priority (shifted into place) (will get set in OS_AddButtonTask)
	NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC
	//dont enable interrupts 
	GPIO_PORTF_PUR_R |= 0x02;	    //add pull up resistor, just for shits and giggles
  
/*	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	  	// Enable GPIOF
  	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);	// make Pin 1 an Input
  	GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1);			//
*/

//TODO: i have no f*****g clue what to do here...

return;
}
コード例 #13
0
//----------------------------------------------------------------------------
// Initialize the ADC
void Init_ADC(void)
{
	int i;
	
	// Init buffer
	for(i=0; i < ADC_BUFFER_SIZE; i++)
	{
		// Initialize to approx 65 degrees F
		adc_buffer[i] = 475.0;
	}
	
	// writes 0x00010000 to RCGC0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER0);


	// Setup timer, 32-bit periodic
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	
	// The prescaler is not available 32-bit mode

	// Load timer value, approx 32Hz
	TimerLoadSet(TIMER0_BASE, TIMER_A, 0x17D784);
    //TimerLoadSet(TIMER0_BASE, TIMER_A, 0xBEBC);
		
	// Configure timer to trigger ADC
	TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

	// Setup ADC
	ADCSequenceDisable(ADC0_BASE, ACTIVE_SS);
    
	// Configure the ADC to trigger off a timer and priority 3 (default)
    ADCSequenceConfigure(ADC0_BASE, ACTIVE_SS, ADC_TRIGGER_TIMER, 3);

    //
    // Configure step 0 on sequence 3.  Sample channel 0 (ADC_CTL_CH0) in
    // single-ended mode (default) and configure the interrupt flag
    // (ADC_CTL_IE) to be set when the sample is done.  Tell the ADC logic
    // that this is the last conversion on sequence 3 (ADC_CTL_END).  Sequence
    // 3 has only one programmable step.  Sequence 1 and 2 have 4 steps, and
    // sequence 0 has 8 programmable steps.  Since we are only doing a single
    // conversion using sequence 3 we will only configure step 0.  For more
    // information on the ADC sequences and steps, reference the datasheet.
    //
    ADCSequenceStepConfigure(ADC0_BASE, ACTIVE_SS, 0, ADC_CTL_CH2 | ADC_CTL_IE |
                             ADC_CTL_END);
    
    ADCHardwareOversampleConfigure(ADC0_BASE, 64);
    
    //
    // Since sample sequence 3 is now configured, it must be enabled.
    //
    ADCSequenceEnable(ADC0_BASE, ACTIVE_SS);

	// Enable ADC interrupt
	ADCIntEnable(ADC0_BASE, ACTIVE_SS);
	IntEnable(INT_ADC0SS3);
	
	// Enable timer
	TimerEnable(TIMER0_BASE, TIMER_A);
	
}
コード例 #14
0
int main(void)
{
    unsigned long adc_result[16];
    unsigned long cnt;
    float temperature;

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);


    //
    // Configure low-level I/O to use printf()
    //
    llio_init(115200);


    //
    // Configure ADC
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS);

    // ADC sequence #0 - setup with 2 conversions
    ADCSequenceDisable(ADC_BASE, 0);
    ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_TIMER, 0);
    ADCIntRegister(ADC_BASE, 0, ADCIntHandler);
    ADCIntEnable(ADC_BASE, 0);

    // sequence step 0 - channel 0
    ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_CH0);
    // sequence step 1 - internal temperature sensor. Generate Interrupt & End of Sequence
    ADCSequenceStepConfigure(ADC_BASE, 0, 1, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);

    ADCSequenceEnable(ADC_BASE, 0);

    //
    // Configure Timer to trigger ADC
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    TimerConfigure( TIMER0_BASE, TIMER_CFG_32_BIT_PER );
    TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
    TimerLoadSet( TIMER0_BASE, TIMER_A, SysCtlClockGet() / 2 );     // 2Hz trigger
    TimerEnable( TIMER0_BASE, TIMER_A );


    printf("\r\n\r\nADC 2 Channel Example\r\n");

    //
    // Loop forever.
    //
    while(1)
    {
        cnt = ADCSequenceDataGet(ADC_BASE, 0, adc_result);
        if (cnt == 2)
        {
            // Calculate temperature
            temperature = (2.7 - (float)adc_result[1] * 3.0 / 1024.) * 75. - 55.;

            printf("%d,%d,%.1f\r\n", adc_result[0], adc_result[1], temperature);
        }
        SysCtlSleep();
    }
}
コード例 #15
0
ファイル: touch.c プロジェクト: VENGEL/StellarisWare
//*****************************************************************************
//
//! Initializes the touch screen driver.
//!
//! This function initializes the touch screen driver, beginning the process of
//! reading from the touch screen.  This driver uses the following hardware
//! resources:
//!
//! - ADC sample sequence 3
//! - Timer 0 subtimer A
//!
//! \return None.
//
//*****************************************************************************
void
TouchScreenInit(void)
{
    unsigned short usController;

    //
    // Set the initial state of the touch screen driver's state machine.
    //
    g_ulTSState = TS_STATE_INIT;

    //
    // There is no touch screen handler initially.
    //
    g_pfnTSHandler = 0;

    //
    // Determine which display controller is in use and, from this, determine
    // what the sense of the Y axis must be.  The -F03 version of the display
    // containing an ILI9320 controller reverses the sense of the Y axis
    // relative to the later -F05 and -F02 versions containing ILI9325 and
    // ILI9328 controllers respectively.
    //
    usController = Formike240x320x16_ILI9320ControllerIdGet();
    g_bReverseLongAxis = ((usController != 0x9320) ? true : false);

    //
    // Enable the peripherals used by the touch screen interface.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

    //
    // Configure the ADC sample sequence used to read the touch screen reading.
    //
    ADCHardwareOversampleConfigure(ADC0_BASE, 4);
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0,
                             ADC_CTL_CH6 | ADC_CTL_END | ADC_CTL_IE);
    ADCSequenceEnable(ADC0_BASE, 3);

    //
    // Enable the ADC sample sequence interrupt.
    //
    ADCIntEnable(ADC0_BASE, 3);
    IntEnable(INT_ADC0SS3);

    //
    // Configure the GPIOs used to drive the touch screen layers.
    //
    GPIOPinTypeGPIOOutput(TS_X_BASE, TS_XP_PIN | TS_XN_PIN);
    GPIOPinTypeGPIOOutput(TS_Y_BASE, TS_YP_PIN | TS_YN_PIN);
    GPIOPinWrite(TS_X_BASE, TS_XP_PIN | TS_XN_PIN, 0x00);
    GPIOPinWrite(TS_Y_BASE, TS_YP_PIN | TS_YN_PIN, 0x00);

    //
    // See if the ADC trigger timer has been configured, and configure it only
    // if it has not been configured yet.
    //
    if((HWREG(TIMER0_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0)
    {
        //
        // Configure the timer to trigger the sampling of the touch screen
        // every millisecond.
        //
        TimerConfigure(TIMER0_BASE, (TIMER_CFG_SPLIT_PAIR |
                                     TIMER_CFG_A_PERIODIC |
                                     TIMER_CFG_B_PERIODIC));
        TimerLoadSet(TIMER0_BASE, TIMER_A, (SysCtlClockGet() / 1000) - 1);
        TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

        //
        // Enable the timer.  At this point, the touch screen state machine
        // will sample and run once per millisecond.
        //
        TimerEnable(TIMER0_BASE, TIMER_A);
    }
}
コード例 #16
0
ファイル: main.c プロジェクト: paulbartell/TissueTester
int main(void) {
	unsigned long ulPeriod = 0;				//Period for Timer0

	//Enable all required peripherals
	PortFunctionInit();

	//Enable console communication with UART
	UARTStdioInit(0);

	//Set system clock to 40 MHz
	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

	/*
	 *
	 * Timer Configuration
	 *
	 */

		//Configure timer to be periodic (counts down and then resets)
		TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

		//Calculate period for a pin toggle freq of 1MHz with 50% duty cycle
		ulPeriod = (SysCtlClockGet() / 10) / 2;
		TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1);

	/*
	 *
	 * ADC0 Configuration
	 *
	 */

		//Set the ADC sample rate to 500 KSPS
		SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS);

		//Disable ADC0 sequencer 3 (so that we can configure it)
		ADCSequenceDisable(ADC0_BASE, 3);
		//Disable ADC1 sequencer 3 (so that we can configure it)
		ADCSequenceDisable(ADC1_BASE, 3);

		//Configure ADC0 sequencer 3 to trigger based on TIMER0A
		ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
		//Configure ADC1 sequencer 3 to trigger based on TIMER0A
		ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_TIMER, 0);

		//Configure the ADC0 to flag the interrupt flag when it finishes sampling
		ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0|ADC_CTL_END|ADC_CTL_IE);
		//Configure the ADC1 to flag the interrupt flag when it finishes sampling
		ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH1|ADC_CTL_END|ADC_CTL_IE);

		//Enable ADC0 sequencer 3
		ADCSequenceEnable(ADC0_BASE, 3);
		//Enable ADC1 sequencer 3
		ADCSequenceEnable(ADC1_BASE, 3);

		//Enable ADC0 interrupt, it's redundant with line 80 but has to be done
		ADCIntEnable(ADC0_BASE, 3);
		//Enable ADC1 interrupt, it's redundant with line 89 but has to be done
		ADCIntEnable(ADC1_BASE, 3);

		//Enable timer
		TimerEnable(TIMER0_BASE, TIMER_A);

		//Configure TIMER0A to be the ADC sample trigger
		TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

		//Clear any interrupts
		ADCIntClear(ADC0_BASE, 3);
		ADCIntClear(ADC1_BASE, 3);

		//Begin sampling
		ADCIntEnable(ADC0_BASE, 3);
		ADCIntEnable(ADC1_BASE, 3);

		//Turn on ADC0 sequence interrupts for sequence 3
		IntEnable(INT_ADC0SS3);
		//Turn on ADC1 sequence interrupts for sequence 3
		IntEnable(INT_ADC1SS3);

		UARTprintf("ADC0 Configured\n");
		UARTprintf("ADC1 Configured\n");

		//Enable all interrupts
		IntMasterEnable();

	while(1) {

	}

}
コード例 #17
0
ファイル: rmb20d01.c プロジェクト: EranSegal/ek-lm4f230H5QR
void RMBD01Init(void)
{


  //
  // Configure the ADC for Pitch and Roll
  // sequence 3 means a single sample
  // sequence 1, 2 means up to 4 samples
  // sequence 0 means up to 8 samples
  // we use sequence 1
  //
  if (SysCtlPeripheralPresent(SYSCTL_PERIPH_ADC0))
  {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);	
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);


    //
    // Configure the pins to be used as analog inputs.
    //
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    //
    // Select the external reference for greatest accuracy.
    //
    //ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

    //
    // Only for LM4F232 Apply workaround for erratum 6.1, in order to use the
    // external reference.
    //
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    //HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) |= GPIO_PIN_6;
	
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); // 1 captures up to 4 samples
    //ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); // 1 captures up to 4 samples


    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ENCODER_CHANNEL_PITCH);     // sample pitch
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ENCODER_CHANNEL_ROLL | ADC_CTL_IE | ADC_CTL_END);     // sample roll

    ADCHardwareOversampleConfigure(ADC0_BASE, 64);
    //ADCSoftwareOversampleConfigure(ADC0_BASE, 0, 8);	

	//ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END));
	ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0);


	//ADCSoftwareOversampleStepConfigure(ADC0_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END));
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0);     // sample roll
    //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);     // sample roll
	    
    //ADCIntRegister(ADC0_BASE,0,ADCIntHandler);

	//
	// Enable the sequencer and interrupt
	//
	ADCSequenceEnable(ADC0_BASE, 3);
	ADCIntEnable(ADC0_BASE, 3);
	IntEnable(INT_ADC3);
	//
	// Zero the oversample counter and the sum
	//
	g_ucOversampleCnt = 0;
	g_ulSum = 0;
	
    //ADCSequenceEnable(ADC0_BASE, 2);
    //ADCIntEnable(ADC0_BASE, 2);

	#if 0
    //
    // Enable the ADC sequencers
    //
    ADCSequenceEnable(ADC0_BASE, 0);

    //
    // Flush the ADC sequencers to be sure there is no lingering data.
    //
    ADCSequenceDataGet(ADC0_BASE, 0, PitchRollAmp);

    //
    // Enable ADC interrupts
    //
    ADCIntClear(ADC0_BASE, 0);
    ADCIntEnable(ADC0_BASE, 0);
    IntEnable(INT_ADC0SS0);

	#else
    //
    // Setup timer for ADC_TRIGGER_TIMER
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	
    //
    // Configure the second timer to generate triggers to the ADC 
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
    TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() / 20000); // 50 us == 20K
    ulTimeSysClock = ROM_SysCtlClockGet()/20000;

  
    TimerControlStall(TIMER1_BASE, TIMER_A, true);
    TimerControlTrigger(TIMER1_BASE, TIMER_A, true);

    //
    // Enable the timers.
    //	
    TimerEnable(TIMER1_BASE, TIMER_A);
	#endif
	
    new_adc = false;
    //
  }
  //
  // Clear outstanding ADC interrupt and enable
  //
  //ADCIntClear(ADC0_BASE, 2);
  //ADCIntEnable(ADC0_BASE, 2);  
  //IntEnable(INT_ADC2);

  //
  // Set the zero current to indicate that the initial sampling has just
  // begun.
  //
  g_usCurrentZero = 0xffff;
} // InitADC