int32_t main(void)
{

	g_ui32SysClock = ROM_SysCtlClockFreqSet(SYSCTL_USE_PLL | SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_CFG_VCO_480, 120000000);

	// Reset index for FFT data
	inputIndex = 0;

	MAP_FPULazyStackingEnable();
	MAP_FPUEnable();

	// Set up ADC sampling and interrupt
	configureADC();

	while(1);                             /* main function does not return */
}
Example #2
0
void main(void)
{
	unsigned char RIGHTCTRL = 3;
 	unsigned char LEFTCTRL = 3;
 	unsigned char UPCTRL = 0;
 	unsigned char LEDCTRL = 0;
 	volatile unsigned char state = 1;

 	configureMSP430();
 	configureAIR();
 	configureADC();
 	while(1)
 	{
		switch(state)
		{
			case 1:
			LEFTCTRL = readLeftJoystick();
			state = 2;
			break;

			case 2:
			RIGHTCTRL = readRightJoystick();
			state = 3;
			break;

			case 3:
			UPCTRL = readUpDown();
			state = 4;
			break;

			case 4:
			LEDCTRL = readLED(LEDCTRL);
			state = 5;
			break;

			case 5:
			runTX(LEFTCTRL, RIGHTCTRL, UPCTRL, LEDCTRL);
			state = 1;
			break;
		}
 	}
}
Example #3
0
//*****************************************************************************
//
// This example application demonstrates the use of the timers to generate
// periodic interrupts.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal at 120MHz.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                             SYSCTL_OSC_MAIN |
                                             SYSCTL_USE_PLL |
                                             SYSCTL_CFG_VCO_480), 120000000);



	// Setup for ultrasonic ranger

	//
	// Enable GPIO M
	//
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

	//
	// Enable GPIO pin for timer event capture (M4).
	//
	ROM_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_4);

	//
	// Configure 7 segment display gpio pins
	//
	sevenSegSetup();

	//
	// Initialize timer for distance pulse measurement.
	//
	ConfigureDistancePulseTimer();

    ROM_FPULazyStackingEnable(); //Enable lazy stacking for faster FPU performance
    ROM_FPUEnable(); //Enable FPU


    TimerACount = 0;
    TimerBCount = 0;
    TimerCCount = 0;
    TimerDCount = 0;

    g_temp_index = 0;
    g_prox_index = 0;
    g_light_index = 0;

    //
    // Initialize the UART and write status.
    //
    ConfigureUART();
    UARTprintf("\033[2J"); //Clear screen

    //UARTprintf("\033[2JFinal Project Timers Example\n");

    configureADC();

    //
    // Enable the peripherals used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //Real Time Clock
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); //Temperature
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); //Proximity
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3); //Light

	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5); //Timer5 is used to measure the leading edge pulses from the signal generator

	// Enable the A peripheral used by the Timer3 pin PA6, PA7
	// Enable the B peripheral used by the Timer5 pin PB2, PB3
	//	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //Enable GPIO A
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Enable GPIO B

	//Configure the pins for its Timer functionality
	ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2); //Enable Timer5 on PB2

	//Configures the alternate function of a GPIO pin for Timer5
	ROM_GPIOPinConfigure(GPIO_PB2_T5CCP0);

    //
    // Enable processor interrupts.
    //
    ROM_IntMasterEnable();

    //
    // Configure the four 32-bit periodic timers.
    //
    ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
    ROM_TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);
    ROM_TimerConfigure(TIMER3_BASE, TIMER_CFG_PERIODIC);
    ROM_TimerConfigure(TIMER5_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT); // Timer5

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock / 10); //RTC       100ms
    ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 5);  //Temp      200ms
    ROM_TimerLoadSet(TIMER2_BASE, TIMER_A, g_ui32SysClock / 2);  //Proximity 500ms
    ROM_TimerLoadSet(TIMER3_BASE, TIMER_A, g_ui32SysClock / 10); //Light     100ms
    ROM_TimerLoadSet(TIMER5_BASE, TIMER_A, 65000); // Timer5

    //Configure the signal edges that triggers the timer when in capture mode
    ROM_TimerControlEvent(TIMER5_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);

    //
    // Setup the interrupts for the timer timeouts.
    //
    ROM_IntEnable(INT_TIMER0A); //RTC
    ROM_IntEnable(INT_TIMER1A); //Temp
    ROM_IntEnable(INT_TIMER2A); //Proximity
    ROM_IntEnable(INT_TIMER3A); //Light
    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); //RTC
    ROM_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); //Temp
    ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT); //Proximity
    ROM_TimerIntEnable(TIMER3_BASE, TIMER_TIMA_TIMEOUT); //Light

    //
    // Enable the timers.
    //
    ROM_TimerEnable(TIMER0_BASE, TIMER_A); //RTC
    ROM_TimerEnable(TIMER1_BASE, TIMER_A); //Temp
    ROM_TimerEnable(TIMER2_BASE, TIMER_A); //Proximity
    ROM_TimerEnable(TIMER3_BASE, TIMER_A); //Light
    ROM_TimerEnable(TIMER5_BASE, TIMER_A); //Timer5

    //
    // Loop forever while the timers run.
    //
    while(1)
    {
    	//Process data (Busy-Wait Loop)
    	//If a flag hasn't been set by the interrupt the calc functions will simply exit
    	//For performance it makes more sense to check flags here instead of at the beginning of the functions
    	calcTemp();     //Calculates Temperature reading
    	calcProx();     //Calculates Proximity reading
    	calcLight();    //Calculates Light reading
    	UARTSendData(); //Sends read data through UART
    }
}