Exemplo n.º 1
1
void confADC(){



	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);   // Habilita ADC0
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0);
	ADCSequenceDisable(ADC0_BASE,0); // Deshabilita el secuenciador 1 del ADC0 para su configuracion


	HWREG(ADC0_BASE + ADC_O_PC) = (ADC_PC_SR_500K);	// usar en lugar de SysCtlADCSpeedSet
	ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 0);// Disparo de muestreo por instrucciones de Timer
	ADCHardwareOversampleConfigure(ADC0_BASE, 64); //SobreMuestreo de 64 muestras

	// Configuramos los 4 conversores del secuenciador 1 para muestreo del sensor de temperatura
	ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); //Sequencer Step 0: Samples Channel PE3
	ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1); //Sequencer Step 1: Samples Channel PE2
	ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END); //Sequencer Step 2: Samples Channel PE1

	IntPrioritySet(INT_ADC0SS0,5<<5);
	// Tras configurar el secuenciador, se vuelve a habilitar
	ADCSequenceEnable(ADC0_BASE, 0);
	//Asociamos la funcion a la interrupcion
	ADCIntRegister(ADC0_BASE, 0,ADCIntHandler);

	//Activamos las interrupciones
	ADCIntEnable(ADC0_BASE,0);


}
Exemplo n.º 2
0
void adc_init_and_run(void){
	// Тактирование выбранного модуля АЦП.
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADCx);

	// Ожидание готовности выбранного модуля АЦП к настройке.
	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADCx)) { }

	ADCHardwareOversampleConfigure(ADCx_BASE, 4);

	// Установка триггера выбранного буфера АЦП.
	ADCSequenceConfigure(ADCx_BASE, SSy, ADC_TRIGGER, 0);

	ADCSequenceStepConfigure(ADCx_BASE, SSy, 0, ADC_CTL_CH0);
	ADCSequenceStepConfigure(
		ADCx_BASE, SSy, 1, ADC_CTL_CH1|ADC_CTL_IE|ADC_CTL_END
	);

	ADCIntClear(ADCx_BASE, SSy);

	IntEnable(INT_ADCxSSy);
	IntPrioritySet(INT_ADCxSSy, 1);

	ADCSequenceEnable(ADCx_BASE, SSy);
	ADCProcessorTrigger(ADCx_BASE, SSy);
}
Exemplo n.º 3
0
//*****************************************************************************
//
//! 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);
}
Exemplo n.º 4
0
int main(void)
{

	uint32_t ui32ADC0Value[4];
	uint32_t ui32Period;
	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
	//Configure ADC to read temperature values
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	ADCHardwareOversampleConfigure(ADC0_BASE, 64);
	//ESpecify the sampler and configure its various stages
	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
	ADCSequenceEnable(ADC0_BASE, 1);
	//Enable peripheral of UART
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	///Configure pins for UART
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
	(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	//Set period of timer interrupts
	ui32Period = (SysCtlClockGet() / 1) / 2;
	TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1);

	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	IntMasterEnable();

	TimerEnable(TIMER0_BASE, TIMER_A);

	while(1)
	{
		ADCIntClear(ADC0_BASE, 1);
		ADCProcessorTrigger(ADC0_BASE, 1);
		while(!ADCIntStatus(ADC0_BASE, 1, false))
		{
		}
		//Update the value of temperature based on readings of ADC
		ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
		ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
		ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
		ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
	}
}
Exemplo n.º 5
0
Arquivo: io.c Projeto: gvb/quickstart
/**
 * Configure the processor's A/D converter subsystem.
 */
static void adc_setup(void)
{
	ADCHardwareOversampleConfigure(ADC0_BASE, ADC_SAC_AVG_OFF);
	ADCReferenceSet(ADC0_BASE, ADC_REF_INT);

	/*
	 * Create a sample sequence for our A/D (what inputs to sample).
	 */
	ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3);
	/* The last conversion is the internal temperature sensor */
	ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_TS |
		ADC_CTL_IE | ADC_CTL_END);
}
Exemplo n.º 6
0
/*
 * Function Name: setup()
 * Input: none
 * Output: none
 * Description: Set system clock frequency and configure ADC
 * Example Call: setup();
 */
void setup(void) {
	SysCtlClockSet(
	SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // CPU is running at 40MHz

	// ADC Configure
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // Enables ADC0
	ADCHardwareOversampleConfigure(ADC0_BASE, 64); // Hardware averages 64 readings and sends it to Sequencer

	// UART Configure
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // UART0 Enabled
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // GPIOA Enabled
	GPIOPinConfigure(GPIO_PA0_U0RX); // Pin 0 of GPIOA set as Rx
	GPIOPinConfigure(GPIO_PA1_U0TX); // Pin 1 of GPIOA set as Tx
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Port A defined as UART Base

	// LED Configure
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // GPIOF Enabled
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,
	GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); // Pin 1,2,3 of Port F set as Output
}
Exemplo n.º 7
0
/*****************************************************
 * 	Function: init_IntTempSensor
 *	Description: Initializes internal temperature
 *			sensor and general timer 1
 *			Uses ADC0 Module and TIMER1
 *	Input: NONE
 *	Output: NONE
 *****************************************************/
void init_IntTempSensor(void)
{
	// Enable clock to ADC0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

	// Configure hardware over-sampling to take 64 samples per step
	// With 4 steps on 64 samples -> 256 samples
	ADCHardwareOversampleConfigure(ADC0_BASE, 64);

	// Configure sequence to trigger on processor trigger
	ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

	// Configure steps 0-3 to read internal temperature sensor
	// Configure step 3 to end conversion
	ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);

	// Enable sequence
	ADCSequenceEnable(ADC0_BASE, 0);
}
Exemplo n.º 8
0
int main(void) {

	char *label = "Temperature: ";
	int i;
	int written = 0;

	uint32_t ui32ADC0Value[4]; 			// ADC FIFO
	volatile uint32_t ui32TempAvg; 		// Store average
	volatile uint32_t ui32TempValueC; 	// Temp in C
	uint32_t ui32TempValueF; 	// Temp in F

	SysCtlClockSet(
			SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
					| SYSCTL_XTAL_16MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	// Set up UART
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //enable GPIO port for LED
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); //enable pin for LED PF2

	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
			(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
	/*
	 IntMasterEnable(); //enable processor interrupts
	 IntEnable(INT_UART0); //enable the UART interrupt
	 UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
	 */
	// Set up ADC module
	SysCtlPeripheralEnable( SYSCTL_PERIPH_ADC0); // enable the ADC0 peripheral
	ADCHardwareOversampleConfigure( ADC0_BASE, 64);	// hardware averaging (64 samples)

	// Configure ADC0 sequencer to use sample sequencer 2, and have the processor trigger the sequence.
	ADCSequenceConfigure( ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);
	// Configure each step.
	ADCSequenceStepConfigure( ADC0_BASE, 2, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure( ADC0_BASE, 2, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure( ADC0_BASE, 2, 2, ADC_CTL_TS);
	// Sample temp sensor.
	ADCSequenceStepConfigure( ADC0_BASE, 2, 3,
			ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
	ADCSequenceEnable( ADC0_BASE, 2); // Enable ADC sequencer 2

	UARTCharPut(UART0_BASE, '\n');
	UARTCharPut(UART0_BASE, '\r');
	for (i = 0; label[i] != '\0'; i++) 	// Print prompt at start of program
		UARTCharPut(UART0_BASE, label[i]);
	UARTCharPut(UART0_BASE, ' ');

	while (1) //let interrupt handler do the UART echo function
	{
		ADCProcessorTrigger(ADC0_BASE, 2); 	// Trigger ADC conversion.

		while (!ADCIntStatus(ADC0_BASE, 2, false))
			; 	// wait for conversion to complete.

		ADCSequenceDataGet(ADC0_BASE, 2, ui32ADC0Value); // get converted data.
		// Average read values, and round.
		// Each Value in the array is the result of the mean of 64 samples.
		ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2]
				+ ui32ADC0Value[3] + 2) / 4;
		ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096) / 10; // calc temp in C
		ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;

		UARTdeleteLastEntry(written);
		written = UARTPrint_uint32_t(ui32TempValueF);
		UARTCharPut(UART0_BASE, 'F');
		written++;

		// LED logic
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED
		SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED
		SysCtlDelay(SysCtlClockGet());
	}
}
Exemplo n.º 9
0
//*****************************************************************************
//
//! 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);
    }
}
Exemplo n.º 10
0
//*****************************************************************************
//
// This function initializes the ADC hardware in preparation for data
// acquisition.
//
//*****************************************************************************
void
AcquireInit(void)
{
    unsigned long ulChan;

    //
    // Enable the ADC peripherals and the associated GPIO port
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);

    ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS);

    ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |GPIO_PIN_7 | GPIO_PIN_3);
    ROM_GPIOPinTypeADC(GPIO_PORTP_BASE, GPIO_PIN_0);

//    ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);
    //ROM_ADCR

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) |= GPIO_PIN_6;
    ADCSequenceDisable(ADC0_BASE,SEQUENCER);

    ROM_ADCSequenceConfigure(ADC0_BASE, SEQUENCER, ADC_TRIGGER_TIMER, 0);

    for(ulChan = 0; ulChan < 2; ulChan++)
    {
        unsigned long ulChCtl;


        if (ulChan ==1)
        {

            ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, ulChan, ADC_CTL_CH1|ADC_CTL_IE | ADC_CTL_END);
        }
        else if(ulChan==0)
        {
        	ulChCtl = ADC_CTL_CH0;
        	ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, ulChan, ADC_CTL_CH0);
        }


    }

    ADCHardwareOversampleConfigure(ADC0_BASE, 1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

    ROM_TimerConfigure(TIMER0_BASE,TIMER_CFG_32_BIT_PER );

    //100 micro
    unsigned long freq=SAMPLING_FREQUENCY;
    unsigned long period=(2*ROM_SysCtlClockGet()/(freq));

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A,period);
    ROM_TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

    //ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
    //ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() /2);




    CFAL96x64x16Init();
    GrContextInit(&sDisplayContext, &g_sCFAL96x64x16);
    sRect1.sXMin = 0;
    sRect1.sYMin = 0;
    sRect1.sXMax = GrContextDpyWidthGet(&sDisplayContext) - 1;
    sRect1.sYMax = 23;

    sRect2.sXMin = 0;
    sRect2.sYMin = 23;
    sRect2.sXMax = GrContextDpyWidthGet(&sDisplayContext) - 1;
    sRect2.sYMax = GrContextDpyHeightGet(&sDisplayContext) - 1;


	snprintf(text,sizeof(text),"STart");


    GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
    GrRectFill(&sDisplayContext, &sRect1);
    GrContextForegroundSet(&sDisplayContext, ClrWhite);
    //GrRectDraw(&sDisplayContext, &sRect1);
    GrContextFontSet(&sDisplayContext, g_pFontCm12);
    GrStringDrawCentered(&sDisplayContext,text, -1,
                         GrContextDpyWidthGet(&sDisplayContext) / 2, 10, 0);

    //GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
    //GrRectFill(&sDisplayContext, &sRect1);
    //GrContextForegroundSet(&sDisplayContext, ClrWhite);
    //GrRectDraw(&sDisplayContext, &sRect1);

    /*GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
    GrRectFill(&sDisplayContext, &sRect2);
    GrContextForegroundSet(&sDisplayContext, ClrWhite);
    GrRectDraw(&sDisplayContext, &sRect2);
*/
    compute_filter();
    maxi1=0;
    maxi2=0;
    max1=0;
    max2=0;
    res=0;
    res1=0;
    g_ulADCCount=0;
    buffer_index=0;
    ulLastADCCount=0;

}
Exemplo n.º 11
0
int main(void)
{
	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	ADCHardwareOversampleConfigure(ADC0_BASE, 64);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //enable GPIO port for LED

	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
	ADCSequenceEnable(ADC0_BASE, 1);

	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
			(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_3); //enable pin for LED PF


	//interrupt section
	IntMasterEnable(); //enable processor interrupts
	IntEnable(INT_UART0); //enable the UART interrupt
	UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

	while(1){
		// Task - 1
		/*ADCIntClear(ADC0_BASE, 1);
		ADCProcessorTrigger(ADC0_BASE, 1);
		while(!ADCIntStatus(ADC0_BASE, 1, false)){}

		ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
		ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
		ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
		ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, 'u');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'n');
		UARTCharPut(UART0_BASE, 't');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, 'T');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'm');
		UARTCharPut(UART0_BASE, 'p');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'a');
		UARTCharPut(UART0_BASE, 't');
		UARTCharPut(UART0_BASE, 'u');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, ' ');
		uint32_t yo = ui32TempValueC;
		int div = 1;
		while(yo!=0){
			yo = yo/10;
			div = div*10;
		}
		yo = ui32TempValueC;
		div = div/10;
		while(div!=0){
			uint32_t remain = yo/div;
			unsigned char xyz = remain+'0';
			UARTCharPut(UART0_BASE, xyz);
			yo = yo - remain*div;
			div = div/10;
		}

		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, '\'');
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, '\r');
		UARTCharPut(UART0_BASE, '\n');
		SysCtlDelay(SysCtlClockGet() / 3);

*/
		// Task - 2
		// monitor
		if(mode==0)
		{
			ADCIntClear(ADC0_BASE, 1);
			ADCProcessorTrigger(ADC0_BASE, 1);
			while(!ADCIntStatus(ADC0_BASE, 1, false))
			{
			}
			ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
			ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
			ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
			ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;


			//led glow code
			if(ui32TempValueC < set_temp)
			{
				GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 8);
			}
			else
			{
				GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 2);
			}

			//display
			UARTCharPut(UART0_BASE, 'C');
			UARTCharPut(UART0_BASE, 'u');
			UARTCharPut(UART0_BASE, 'r');
			UARTCharPut(UART0_BASE, 'r');
			UARTCharPut(UART0_BASE, 'e');
			UARTCharPut(UART0_BASE, 'n');
			UARTCharPut(UART0_BASE, 't');
			UARTCharPut(UART0_BASE, ' ');
			UARTCharPut(UART0_BASE, 'T');
			UARTCharPut(UART0_BASE, 'e');
			UARTCharPut(UART0_BASE, 'm');
			UARTCharPut(UART0_BASE, 'p');
			UARTCharPut(UART0_BASE, ' ');

			uint32_t yo = ui32TempValueC;
			int div = 1;
			while(yo!=0){
				yo = yo/10;
				div = div*10;
			}
			yo = ui32TempValueC;
			div = div/10;
			while(div!=0){
				uint32_t remain = yo/div;
				unsigned char xyz = remain+'0';
				UARTCharPut(UART0_BASE, xyz);
				yo = yo - remain*div;
				div = div/10;
			}

			UARTCharPut(UART0_BASE, ' ');
			unsigned char xyz = 176;
			UARTCharPut(UART0_BASE, xyz);
			UARTCharPut(UART0_BASE, 'C');

			UARTCharPut(UART0_BASE, ',');
			UARTCharPut(UART0_BASE, ' ');

			UARTCharPut(UART0_BASE, 'S');
			UARTCharPut(UART0_BASE, 'e');
			UARTCharPut(UART0_BASE, 't');
			UARTCharPut(UART0_BASE, ' ');
			UARTCharPut(UART0_BASE, 'T');
			UARTCharPut(UART0_BASE, 'e');
			UARTCharPut(UART0_BASE, 'm');
			UARTCharPut(UART0_BASE, 'p');
			UARTCharPut(UART0_BASE, ' ');

			yo = set_temp;
			div = 1;
			while(yo!=0){
				yo = yo/10;
				div = div*10;
			}
			yo = set_temp;
			div = div/10;
			while(div!=0){
				uint32_t remain = yo/div;
				unsigned char xyz = remain+'0';
				UARTCharPut(UART0_BASE, xyz);
				yo = yo - remain*div;
				div = div/10;
			}

			UARTCharPut(UART0_BASE, ' ');
			UARTCharPut(UART0_BASE, xyz);
			UARTCharPut(UART0_BASE, 'C');
			UARTCharPut(UART0_BASE, '\r');
			UARTCharPut(UART0_BASE, '\n');
			SysCtlDelay(30000000);
		}
	}
}
Exemplo n.º 12
0
//*****************************************************************************
//
//! 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);
    }
}
Exemplo n.º 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);
	
}
Exemplo n.º 14
0
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
Exemplo n.º 15
0
void hardware_init(void)
{
	//Set PWM clock at the same frequency as system clock
	SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

	/*
	 * Inverter system setup
	 * period : Switching Frequency : 20Khz
	 * cycle : Duty Cycle SPWM
	 * deadband : Deadband
	 */
	inv.period = SysCtlClockGet()/20000;
	inv.deadband = 25*inv.period/100;
	inv.cycle = inv.period*500/1000;

	/*
	 * Boost converter system setup
	 * period: Switching frequency: 20kHz
	 * cycle: Duty cycle
	 * deadband: Deadband
	 */
	conv.period = inv.period;
	conv.deadband = inv.deadband;
	conv.cycle = conv.period*500/1000;

	/*
	 * Setup SPWM on PWM0 GEN0 and GEN1
	 * PB6 : PWM0 GEN0
	 * PB7: PWM0 GEN1
	 */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	SysCtlPeripheralReset(SYSCTL_PERIPH_PWM0);
	SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOB);

	GPIOPinConfigure(GPIO_PB6_M0PWM0);
	GPIOPinConfigure(GPIO_PB7_M0PWM1);

	GPIOPinTypePWM(GPIO_PORTB_BASE, (GPIO_PIN_6 | GPIO_PIN_7));

	PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_SYNC_LOCAL | PWM_GEN_MODE_FAULT_UNLATCHED | PWM_GEN_MODE_DB_NO_SYNC));
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, inv.period-1);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, inv.cycle);
	PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 13, 0);
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT, true);

	PWMSyncUpdate(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT);

	/*
	 * Setup boost converter pwm on PWM1
	 * PA6: PWM1 GEN1
	 */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	SysCtlPeripheralReset(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOA);

	GPIOPinConfigure(GPIO_PA6_M1PWM2);	//Map PWM1, P1 OP2 to PA6
	GPIOPinTypePWM(GPIO_PORTA_BASE, GPIO_PIN_6);	//Configure PA6 as PWM

	PWMGenConfigure(PWM1_BASE, PWM_GEN_1, (PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_GEN_NO_SYNC| PWM_GEN_MODE_DB_NO_SYNC));	//Configure PWM1, G1 as Down counter with no sync of updates
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_1, conv.period-1);	//Set Period of PWM1, G1
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_2, conv.cycle);	//Set phase shift

	PWMIntEnable(PWM1_BASE, PWM_INT_GEN_1);
	PWMGenIntTrigEnable(PWM1_BASE, PWM_GEN_1, PWM_TR_CNT_LOAD|PWM_INT_CNT_LOAD);
	IntPrioritySet(INT_PWM1_1, 0x02);
	PWMOutputState(PWM1_BASE, PWM_OUT_2_BIT, true);

	PWMGenEnable(PWM1_BASE, PWM_GEN_1);

	/*
	 * Setup ISR for updating SPWM duty cycle
	 */
	uint32_t ui32TimIntSine = SysCtlClockGet()/200000;

	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

	SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER2);

	TimerConfigure(TIMER2_BASE, TIMER_CFG_A_PERIODIC);
	TimerLoadSet(TIMER2_BASE, TIMER_A, ui32TimIntSine-1);

	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	IntPrioritySet(INT_TIMER2A, 0x03);
	TimerEnable(TIMER2_BASE, TIMER_A);

	uint32_t ui32TimIntIcontrol = SysCtlClockGet()/40000;

	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER1);

	TimerConfigure(TIMER1_BASE, TIMER_CFG_A_PERIODIC);
	TimerLoadSet(TIMER1_BASE, TIMER_A, ui32TimIntIcontrol-1);

	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	IntPrioritySet(INT_TIMER1A, 0x01);
	TimerEnable(TIMER1_BASE, TIMER_A);

	/*
	 * Setup PF1 as debug pin
	 */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

//	SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOF);

	HWREG(0x40005520) = 0x4C4F434B;
	HWREG(0x40005524) |= 0x01;
	HWREG(0x40005520) = 0x00;

	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);

	GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

	GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);

	IntPrioritySet(INT_GPIOF,0x00);
	GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);

	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

	/*
	 * Setup ADC
	 * Configuration currently in discussion
	 * Interrupt at end might not be necessary
	 */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

	SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);

	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1);
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

	SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);

	ADCHardwareOversampleConfigure(ADC0_BASE, 2);
	ADCSequenceDisable(ADC0_BASE, 2);

	ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PWM1, 0x00);
	HWREG(0x4003801C) |= 0x1000;	//Sec 13.4.2 Pt 3

	ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH1);

	ADCSequenceStepConfigure(ADC0_BASE, 2, 1, ADC_CTL_CH2);

	ADCSequenceStepConfigure(ADC0_BASE, 2, 2, ADC_CTL_CH3|ADC_CTL_IE|ADC_CTL_END);

	ADCSequenceEnable(ADC0_BASE, 2);
}