예제 #1
0
파일: Iot_Pwm.c 프로젝트: sdhczw/Aircleaner
/*********************************************************************************************************
** Function name:           SetFanPwm
** Descriptions:            
** input parameters:        
**                          
** Output parameters::      нч
** Returned value:          
**                          
** Created by:              
** Created Date:            
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
u8 GetFanPwm()
{
     // Set the Timer1B match value to load value / 3.
    //
    return (TimerMatchGet(WTIMER2_BASE, TIMER_B)*100)/TimerLoadGet(WTIMER2_BASE, TIMER_B);
   
}
예제 #2
0
파일: Iot_Pwm.c 프로젝트: sdhczw/Aircleaner
/*********************************************************************************************************
** Function name:           SetFanPwm
** Descriptions:            
** input parameters:        
**                          
** Output parameters::      нч
** Returned value:          
**                          
** Created by:              
** Created Date:            
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void SetFanPwmOut(u8 u8PwmValue)
{
     // Set the Timer1B match value to load value / 3.
    //
    TimerMatchSet(WTIMER2_BASE, TIMER_B,
                  TimerLoadGet(WTIMER2_BASE, TIMER_B) *u8PwmValue/100);

}
예제 #3
0
파일: Iot_Pwm.c 프로젝트: sdhczw/Aircleaner
/*********************************************************************************************************
** Function name:           ConfigureFanPWM
** Descriptions:            
** input parameters:        
**                          
** Output parameters::      нч
** Returned value:          
**                          
** Created by:     zhangwen          
** Created Date:            
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void ConfigureFanPWM(u8 u8DefaulPwm)
{
    
  //
    // The Timer1 peripheral must be enabled for use.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER2);



    //
    // Configure the GPIO pin muxing for the Timer/CCP function.
    // This is only necessary if your part supports GPIO pin function muxing.
    // Study the data sheet to see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using
    //
    GPIOPinConfigure(GPIO_PD1_WT2CCP1);

    //
 

    //
    // Configure the ccp settings for CCP pin.  This function also gives
    // control of these pins to the SSI hardware.  Consult the data sheet to
    // see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using.
    //
    GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_1);


    //
    // Configure Timer1B as a 16-bit periodic timer.
    //
    TimerConfigure(WTIMER2_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM);

    //
    // Set the Timer1B load value to 50000.  For this example a 66% duty cycle
    // PWM signal will be generated.  From the load value (i.e. 50000) down to
    // match value (set below) the signal will be high.  From the match value
    // to 0 the timer will be low.
    //
    TimerLoadSet(WTIMER2_BASE, TIMER_B, 50000);

    //
    // Set the Timer1B match value to load value / 3.
    //
    TimerMatchSet(WTIMER2_BASE, TIMER_B,
                  TimerLoadGet(WTIMER2_BASE, TIMER_B) *u8DefaulPwm/100);

    //
    // Enable Timer1B.
    //
    TimerEnable(WTIMER2_BASE, TIMER_B);

    //
    // Loop forever while the Timer1B PWM runs.
}
예제 #4
0
void high_to_low(void)
{

		TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B)/2);

		TimerEnable(TIMER0_BASE, TIMER_B);

		SysCtlDelay(SysCtlClockGet()/50);

		TimerDisable(TIMER0_BASE, TIMER_B);

		TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B)/4);

		TimerEnable(TIMER0_BASE, TIMER_B);

		SysCtlDelay(SysCtlClockGet()/50);

		TimerDisable(TIMER0_BASE, TIMER_B);

		TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B)/6);

		TimerEnable(TIMER0_BASE, TIMER_B);

		SysCtlDelay(SysCtlClockGet()/50);

		TimerDisable(TIMER0_BASE, TIMER_B);

		TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B)/8);

		TimerEnable(TIMER0_BASE, TIMER_B);

		SysCtlDelay(SysCtlClockGet()/50);

		TimerDisable(TIMER0_BASE, TIMER_B);

		TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B)/10);

		TimerEnable(TIMER0_BASE, TIMER_B);

		SysCtlDelay(SysCtlClockGet()/50);

		TimerDisable(TIMER0_BASE, TIMER_B);

	}
예제 #5
0
void pwm1(unsigned long val1)
{
       /*if(val1 <= 1)
       {
    	   val1=0;
        }
       else
    	 val1=val1-1;
        */
		TimerMatchSet(TIMER0_BASE, TIMER_A, TimerLoadGet(TIMER0_BASE, TIMER_A)*val1/256);
		TimerEnable(TIMER0_BASE, TIMER_A);
}
예제 #6
0
파일: QRB1134.c 프로젝트: zlalanne/EE345M
void Timer0A_Handler(void){
        static unsigned long Counter = 0;  // may interrupt from timeouts multiple times before edge
        unsigned long ulIntFlags = TimerIntStatus(TIMER0_BASE, true);
        TimerIntClear(TIMER0_BASE, ulIntFlags);// acknowledge
       if(ulIntFlags & TIMER_TIMA_TIMEOUT) {
                Counter++;	// keep track of timeouts
        }
        
        if(ulIntFlags & TIMER_CAPA_EVENT) {
                Period = Last - TimerValueGet(TIMER0_BASE, TIMER_A) + Counter*TimerLoadGet(TIMER0_BASE, TIMER_A);
                Last = TimerValueGet(TIMER0_BASE, TIMER_A);
                Counter = 0;
        }
}
예제 #7
0
//*****************************************************************************
//
// Configure Timer1B as a 16-bit PWM with a duty cycle of 66%.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the external crystal/oscillator.
    // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
    // crystal on your board.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_16MHZ);

    //
    // The Timer1 peripheral must be enabled for use.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

    //
    // For this example CCP3 is used with port E pin 4.
    // The actual port and pins used may be different on your part, consult
    // the data sheet for more information.
    // GPIO port E needs to be enabled so these pins can be used.
    // TODO: change this to whichever GPIO port you are using.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    //
    // Configure the GPIO pin muxing for the Timer/CCP function.
    // This is only necessary if your part supports GPIO pin function muxing.
    // Study the data sheet to see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using
    //
    GPIOPinConfigure(GPIO_PE4_CCP3);

    //
    // Set up the serial console to use for displaying messages.  This is
    // just for this example program and is not needed for Timer/PWM operation.
    //
    InitConsole();

    //
    // Configure the ccp settings for CCP pin.  This function also gives
    // control of these pins to the SSI hardware.  Consult the data sheet to
    // see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using.
    //
    GPIOPinTypeTimer(GPIO_PORTE_BASE, GPIO_PIN_4);

    //
    // Display the example setup on the console.
    //
    UARTprintf("16-Bit Timer PWM ->");
    UARTprintf("\n   Timer = Timer1B");
    UARTprintf("\n   Mode = PWM");
    UARTprintf("\n   Duty Cycle = 66%%\n");
    UARTprintf("\nGenerating PWM on CCP3 (PE4) -> ");

    //
    // Configure Timer1B as a 16-bit periodic timer.
    //
    TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR |
                   TIMER_CFG_B_PWM);

    //
    // Set the Timer1B load value to 50000.  For this example a 66% duty
    // cycle PWM signal will be generated.  From the load value (i.e. 50000)
    // down to match value (set below) the signal will be high.  From the
    // match value to 0 the timer will be low.
    //
    TimerLoadSet(TIMER1_BASE, TIMER_B, 50000);

    //
    // Set the Timer1B match value to load value / 3.
    //
    TimerMatchSet(TIMER1_BASE, TIMER_B, TimerLoadGet(TIMER1_BASE, TIMER_B) / 3);

    //
    // Enable Timer1B.
    //
    TimerEnable(TIMER1_BASE, TIMER_B);

    //
    // Loop forever while the Timer1B PWM runs.
    //
    while(1)
    {
        //
        // Print out indication on the console that the program is running.
        //
        PrintRunningDots();
    }
}
예제 #8
0
//
// returns idle timer running status, indicates whether lights are still on or not
//
bool idleTimerRunning() {
	return TimerValueGet(TIMER1_BASE, TIMER_A)
			!= TimerLoadGet(TIMER1_BASE, TIMER_A);
}
uint32_t CommutationControllerClass::getTimeoutValue()
{
	return TimerLoadGet(TIMER_BASE, TIMER_A);
}
예제 #10
0
void pwm3(unsigned long val3)
{
		TimerMatchSet(TIMER2_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_A)*val3/256);
        TimerEnable(TIMER2_BASE, TIMER_B);
}
예제 #11
0
void pwm2(unsigned long val2)
{
		TimerMatchSet(TIMER1_BASE, TIMER_A, TimerLoadGet(TIMER0_BASE, TIMER_A)*val2/256);
		TimerEnable(TIMER1_BASE, TIMER_A);
}