예제 #1
0
파일: main.c 프로젝트: NHLBI-MR/PRiME
void Setup1msTimer(void)
{
    //Start timer in continuous mode sourced by SMCLK
    //Timer_A_initContinuousModeParam initUpParam = {0};
    Timer_A_initUpModeParam initUpParam = {0};

    initUpParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK;
    initUpParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    initUpParam.timerInterruptEnable_TAIE =
    		TIMER_A_TAIE_INTERRUPT_DISABLE;
    initUpParam.timerClear = TIMER_A_DO_CLEAR;
    initUpParam.startTimer = false;
    Timer_A_initUpMode(TIMER_A1_BASE, &initUpParam);

    //Initiaze compare mode
    Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE,
    		TIMER_A_CAPTURECOMPARE_REGISTER_0);

    Timer_A_initCompareModeParam initCompParam = {0};
    initCompParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_0;
    initCompParam.compareInterruptEnable =
    		TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE;
    initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_OUTBITVALUE;
    initCompParam.compareValue = UCS_getSMCLK()/1e3;
    Timer_A_initCompareMode(TIMER_A1_BASE, &initCompParam);

    Timer_A_startCounter(TIMER_A1_BASE,TIMER_A_UP_MODE);
}
예제 #2
0
//this interrupt is triggered once each second and prints result from ADC conversion and clears interrupt flag
void timer_A_ISR(){ //Timers_A_ISR runs at 1 Hz
	//Turn light to signal timer interrupt is working
	MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
	MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN0);


	Timer_A_clearCaptureCompareInterrupt(TIMER_A0_MODULE,TIMER_A_CAPTURECOMPARE_REGISTER_0);
	printf("%f \n",(ADC_result/1023.0)*3.3*100.0);//(float)ADC_result);// also try 100.0 as a fix!!!    (ADC_result/1023.0)*198.0); //  150F/2.5V = 60F per V. Thus, 150+(3.3-2.5)*60 = 198
															  //  This conversion is necessary because 0-2.5 V corresponds to 0-150F
															  //  On the microncontroller, 0-3.3 V corresponds to 0-1023 binary
															  //  And the result of the ADC is a binary value

	//Turn off LED's
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0);
}