示例#1
1
int main(void)
{
	volatile uint32_t ui32Load;
	volatile uint32_t ui32PWMClock;
	volatile uint8_t ui8Adjust;
	ui8Adjust = 254;

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
	SysCtlPWMClockSet(SYSCTL_PWMDIV_64);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinConfigure(GPIO_PF1_M1PWM5);

	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
	GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

	ui32PWMClock = SysCtlClockGet() / 64;
	ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ui32Load);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);

	while(1)
	{

		if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00)
		{
			ui8Adjust--;
			if (ui8Adjust < 10)
			{
				ui8Adjust = 10;
			}
			PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
		}

		if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00)
		{
			ui8Adjust++;
			if (ui8Adjust > 254)
			{
				ui8Adjust = 254;
			}
			PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
		}

		SysCtlDelay(100000);
	}

}
//******************************************************************
// Initialise the PWM generator (PWM1 & PWM4)
//******************************************************************
void
initPWMchan (void)
{
	unsigned long period;

    SysCtlPeripheralEnable (SYSCTL_PERIPH_PWM);
    //
    // Compute the PWM period based on the system clock.
    //
        SysCtlPWMClockSet (PWM_DIV_CODE);

    PWMGenConfigure (PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenConfigure (PWM_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    period = SysCtlClockGet () / PWM_DIVIDER / MOTOR_RATE_HZ;
    PWMGenPeriodSet (PWM_BASE, PWM_GEN_0, period);
    PWMGenPeriodSet (PWM_BASE, PWM_GEN_2, period);
    PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty / 100);
    PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty / 100);
    //
    // Enable the PWM output signal.
    //
    PWMOutputState (PWM_BASE, PWM_OUT_1_BIT, false);
    PWMOutputState (PWM_BASE, PWM_OUT_4_BIT, false);
    //
    // Enable the PWM generator.
    //
    PWMGenEnable (PWM_BASE, PWM_GEN_0);
    PWMGenEnable (PWM_BASE, PWM_GEN_2);
}
int main(void)
{

	SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable the GPIO A ports
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Enable the GPIO E ports
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	GPIOPinConfigure(GPIO_PB6_M0PWM0);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);

	GPIOPinConfigure(GPIO_PB7_M0PWM1);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

	PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 6400000);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_0) / 1.25);
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);

	PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 6400000);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / 1.25);
	PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true);
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);


	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6|GPIO_PIN_7); // Set pin 7 as the output port
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_5);


	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7
	GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4);
	while(1)
	{
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4);
		SysCtlDelay(4000000*10);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7
	    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0);
	    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32);
	    SysCtlDelay(400000);
	    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,128); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,2);
		SysCtlDelay(4000000*10);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7
		GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32);
		SysCtlDelay(400000);
		GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);

	}
}
示例#4
0
文件: servo.c 项目: RAS-MoFos/RASLib
// Summary:	Initializes the appropriate PWMs for servo output
// Note:	Always call this function before any other servo-related functions
void InitializeServos(void)
{						
	unsigned long ulServoPeriod;

	//
	// Enable the peripherals used by the servos.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);	// servos 0 & 1
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	// servos 2 & 3
	   
    //
    // Set GPIO B0, B1, D0, and D1 as PWM pins. 
    // They are used to output the PWM0, PWM2, PWM3, and PWM3 signals.
    //
    GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Compute the PWM period based on the system clock.
    //
    ulServoPeriod = g_ulPWMTicksPerSecond / 50;

    //
    // Set the PWM period to 50 Hz = 20ms.
    //
    PWMGenConfigure(PWM_BASE, PWM_GEN_0,
                    PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, ulServoPeriod);
    PWMGenConfigure(PWM_BASE, PWM_GEN_1,
                    PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenPeriodSet(PWM_BASE, PWM_GEN_1, ulServoPeriod);
    
    
    us600 = ulServoPeriod * 3 / 100;	// 20 ms * 3 / 100 = 600 us
    us2400 = us600 * 4;				// 600 us * 4 = 2400 us

    //
    // Enable the PWM0, PWM1, PWM2, and PWM3 output signals.
    //
    PWMOutputState(PWM_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT, true);

    //
    // Enable the PWM generator.
    //
    PWMGenEnable(PWM_BASE, PWM_GEN_0);
    PWMGenEnable(PWM_BASE, PWM_GEN_1);

	// Default to center
	SetServoPosition(SERVO_0, SERVO_NEUTRAL_POSITION);
	SetServoPosition(SERVO_1, SERVO_NEUTRAL_POSITION);
	SetServoPosition(SERVO_2, SERVO_NEUTRAL_POSITION);
	SetServoPosition(SERVO_3, SERVO_NEUTRAL_POSITION);
}
示例#5
0
void MotorInit(uint8_t report)
{

	SystickInit(1);
	// 设置PWM时钟和系统时钟一致
	SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

	 // 使能PWM外设
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	// 使能外设端口
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	//设置对应管脚的PWM信号功能
	GPIOPinConfigure(GPIO_PB4_M0PWM2);
	GPIOPinConfigure(GPIO_PB5_M0PWM3);
	GPIOPinConfigure(GPIO_PB6_M0PWM0);
	GPIOPinConfigure(GPIO_PB7_M0PWM1);

	//设置PWM信号端口
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);

	//PWM生成器配置
	PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
	PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);

	//设置PWM信号周期
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, PERIOD_TIME);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, PERIOD_TIME);

	//设置PWM信号占空比
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 0);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 0);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, 0);

	// 使能PWM输出端口
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT|PWM_OUT_2_BIT|PWM_OUT_3_BIT, true);

	// 使能PWM生成器
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);

	// 使能PWm生成器模块的及时功能.
	PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0);
	PWMSyncTimeBase(PWM0_BASE, PWM_GEN_1);

	if(report)
		UARTprintf("PWM初始化完成!\r\n");
}
示例#6
0
int main(void)
{
	volatile uint32_t ui32Load;
	volatile uint32_t ui32PWMClock;
	uint32_t ui32Period;

	setup();

	ui32PWMClock = SysCtlClockGet() / 64;
	ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ui32Load);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ui32Load);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, red * ui32Load / 240);		// RED
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, green * ui32Load / 240);		// GREEN
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, blue * ui32Load / 240);		// BLUE

	PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT | PWM_OUT_6_BIT | PWM_OUT_7_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);
	PWMGenEnable(PWM1_BASE, PWM_GEN_3);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

	ui32Period = (SysCtlClockGet() / 100) ;
	TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period - 1);		// Change here

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

	while(1)
	{
		if(mode == 0)
		{
			angle = angle + incAngle;
			changeColor();
		}

		PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, red * ui32Load / 240);		// RED
		PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, green * ui32Load / 240);		// GREEN
		PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, blue * ui32Load / 240);		// BLUE

		SysCtlDelay(1000000);
	}
}
示例#7
0
//PWM³õʼ»¯
void initPWM()
{
    //³õʼ»¯ÍâÉè¶Ë¿Ú
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);  
    
    //ÉèÖÃPWMÐźÅʱÖÓ
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    
    //ÉèÖÃPG2ºÍPD1ΪPWMÊä³ö
    GPIOPinConfigure(GPIO_PG2_PWM0);
    GPIOPinConfigure(GPIO_PD1_PWM1);
    GPIOPinTypePWM(GPIO_PORTG_BASE, PWM_L);
    GPIOPinTypePWM(GPIO_PORTD_BASE, PWM_R);
    
    //ÅäÖÃPWM·¢ÉúÄ£¿é1
    PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN|PWM_GEN_MODE_NO_SYNC);
    //PWMGenConfigure(PWM_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN|PWM_GEN_MODE_NO_SYNC);

    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 1000);
    //PWMGenPeriodSet(PWM_BASE, PWM_GEN_3, 800);
    
   // PWMPulseWidthSet(PWM_BASE, PWM_OUT_0,700);//×ó
   // PWMPulseWidthSet(PWM_BASE, PWM_OUT_1,500);//ÓÒ
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_0,banlanceL);//×ó
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_1,banlanceR);//ÓÒ
    //ʹÄÜPWM2Êä³ö
    PWMOutputState(PWM_BASE,PWM_OUT_0_BIT,true);
    //ʹÄÜPWM3Êä³ö
    PWMOutputState(PWM_BASE,PWM_OUT_1_BIT,true);
    
    PWMGenEnable(PWM_BASE, PWM_GEN_0);
}
示例#8
0
//*****************************************************************************
//
// Set up the PWM0 output to be used as a signal source for the CCP1 input
// pin.  This example application uses PWM0 as the signal source in order
// to demonstrate the CCP usage and also to provide a predictable timing
// source that will produce known values for the capture timer.  In a real
// application some external signal would be used as the signal source for
// the CCP input.
//
//*****************************************************************************
static void
SetupSignalSource(void)
{
    //
    // Enable the GPIO port used for PWM0 output.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    //
    // Enable the PWM peripheral and configure the GPIO pin
    // used for PWM0.  GPIO pin D0 is used for PWM0 output.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
    GPIOPinConfigure(GPIO_PD0_PWM0);
    GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0);

    //
    // Configure the PWM0 output to generate a 50% square wave with a
    // period of 5000 processor cycles.
    //
    PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
    PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, TIMEOUT_VAL);
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, TIMEOUT_VAL / 2);
    PWMOutputState(PWM_BASE, PWM_OUT_0_BIT, 1);
    PWMGenEnable(PWM_BASE, PWM_GEN_0);
}
示例#9
0
void motors_init(void) {

	int i;
	uint8_t pin_mask;
	uint32_t motor_per;

	// Set Pins to output/PWM in GPIO
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	GPIOPinConfigure(GPIO_PF2_M1PWM6);
	GPIOPinConfigure(GPIO_PF3_M1PWM7);
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);

	// Configure the pin for standby control
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);

	SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
	// Configure the PWM for each pin:
	// Turn on the generators and set the PW to 0
	// The output is still OFF. Turn on with set_motor_pwm_state
	for (i = 0; i < NUM_MOTORS; i++) {
		PWMGenConfigure(motors[i].pwm_base_module, motors[i].pwm_generator, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
		motor_per = calc_cycles(MOTOR_PERIOD);
		PWMGenPeriodSet(motors[i].pwm_base_module, motors[i].pwm_generator, motor_per);
		PWMPulseWidthSet(motors[i].pwm_base_module, motors[i].pwm_pin, 0);
		PWMGenEnable(motors[i].pwm_base_module, motors[i].pwm_generator);
		pin_mask = 1 << (0x0000000F & motors[i].pwm_pin);
		PWMOutputState(motors[i].pwm_base_module, pin_mask, 0);
	}

}
void DRV8833_InitMotorA(){
	if(!SysCtlPeripheralReady(SYSCTL_PERIPH_PWM0))
		SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	if(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB))
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlDelay(3);
	GPIOPinConfigure(GPIO_PB6_M0PWM0);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_6,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
	PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_1);
	PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
			PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);


	uint32_t duty = 0;
	PWMOutputUpdateMode(PWM0_BASE,PWM_OUT_0_BIT|PWM_OUT_1_BIT,PWM_OUTPUT_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, freq);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, duty);
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);


	GPIOPinConfigure(GPIO_PB7_M0PWM1);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_7,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, duty);
	PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true);

	PWMGenEnable(PWM0_BASE, PWM_GEN_0);
}
void DRV8833_InitMotorB(){
	if(!SysCtlPeripheralReady(SYSCTL_PERIPH_PWM0))
		SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

	if(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB))
		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlDelay(3);


	GPIOPinConfigure(GPIO_PB4_M0PWM2);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
	PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_1);
	PWMGenConfigure(PWM0_BASE, PWM_GEN_1,
			PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);

	uint32_t duty = 0;
	PWMOutputUpdateMode(PWM0_BASE,PWM_OUT_2_BIT|PWM_OUT_3_BIT,PWM_OUTPUT_MODE_NO_SYNC);
	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, freq);
	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, duty);
	PWMOutputState(PWM0_BASE, PWM_OUT_2_BIT, true);


	GPIOPinConfigure(GPIO_PB5_M0PWM3);
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_5);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);

	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, duty);
	PWMOutputState(PWM0_BASE, PWM_OUT_3_BIT, true);

	HWREG(GPIO_PORTB_BASE+GPIO_O_AFSEL) &= ~0x30;
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);
}
示例#12
0
void PWM_Setup()
{
	SysCtlPWMClockSet(PWM_SYSCLK_DIV_64);
	//
	// Configure the PWM generator for count down mode with immediate updates
	// to the parameters.
	//
	PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
	// Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20
	// microseconds. For a 20 MHz clock, this translates to 400 clock ticks.
	// Use this value to set the period.
	//
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, MAXPERIOD);
	//
	// Set the pulse width of PWM1 for a 75% duty cycle.
	//
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, 0);
	
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, 0);
	// 50MHZ is to fast
	PWMClockSet(PWM1_BASE,PWM_SYSCLK_DIV_64);
	//
	// Start the timers in generator 3.
	//
	PWMGenEnable(PWM1_BASE, PWM_GEN_3);
	//
	// Enable the outputs.
	//
	PWMOutputState(PWM1_BASE, PWM_OUT_6_BIT , true);

}
示例#13
0
//--------------------------------
void pwm_stepper::Move(uint32_t nSteps) {
	m_nSteps = nSteps;
	m_nSpeed = m_nStartSpeed;
	m_nPhase = Phase_Accel;
	PWMGenPeriodSet(Base, Generator, m_nSpeed);
	PWMPulseWidthSet(Base, PWM_OUT_2, 64);
	PWMGenEnable(Base, Generator);
}
示例#14
0
	void ConfiguracionPWM(uint8_t Ancho){
		PWMClock = SysCtlClockGet() / 64;
		Load = (PWMClock / Frecuencia) - 1;
		PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
		PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, Load);
		PWMOutputState(PWM1_BASE, PWM_OUT_0_BIT, true);
		PWMGenEnable(PWM1_BASE, PWM_GEN_0);
	}
示例#15
0
//*****************************************************************************
//
// Interrupt handlers
//
//*****************************************************************************
void
SysTickIntHandler(void){
	// Handle state changes
	if (done){
		tick++;
		if (tick>1){
			if (lose){
				// Turn off the noise
				PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false);
				PWMGenDisable(PWM0_BASE, PWM_GEN_0);
				unsigned long ulPeriod = SysCtlClockGet() / 220;

				// Set the PWM period to 220 (A) Hz.
				PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
						PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
				PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);

				// Make some noise again
				PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);
				PWMGenEnable(PWM0_BASE, PWM_GEN_0);
			}
		}
		if (tick>2){
			if (lose){
				// Turn off the noise
				PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false);
				PWMGenDisable(PWM0_BASE, PWM_GEN_0);

				unsigned long ulPeriod = SysCtlClockGet() / 440;
				// Set the PWM period to 440 (A) Hz. again
				PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
						PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
				PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);
				lose = 0;
			}
			if (state==1){
				startClassic();
				tick = 0;
				done = 0;
			}
			else if(state==2){
				if(tick>4){
					RIT128x96x4Clear();
					initMain();
					state = 0;
					pointer = 0;
					tick = 0;
					done = 0;
				}
			}
			else if (state==3){
				startContinuous();
				tick = 0;
				done = 0;
			}
		}
	}
}
示例#16
0
void GreenSetup(volatile uint8_t ui8Adjust){
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_3);
	GPIOPinConfigure(GPIO_PF3_M1PWM7);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ui32Load);
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, ui8Adjust * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_7_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_3);
}
示例#17
0
void RedSetup(volatile uint8_t ui8Adjust){
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinConfigure(GPIO_PF1_M1PWM5);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ui32Load);
	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);
}
示例#18
0
//--------------------------------
void pwm_stepper::OnInterrupt() {
	m_nSteps--;
	if (0 >= m_nSteps) {
		m_nSteps = 0;
		m_nPhase = Phase_Stop;
	}
	if (m_bDirectionForward) {
		m_nRelativeSteps++;
	} else {
		m_nRelativeSteps--;
	}
	switch (m_nPhase) {
	case Phase_Accel:
		m_nSpeed -= m_nAcceleration;
		if (m_nTargetSpeed >= m_nSpeed) {
			m_nSpeed = m_nTargetSpeed;
			m_nPhase = Phase_Steady;
		}
		PWMGenPeriodSet(Base, Generator, m_nSpeed);
		PWMPulseWidthSet(Base, PWM_OUT_2, 64);
		PWMGenEnable(Base, Generator);
		break;
	case Phase_Steady:
		if (m_nSteps <= ((Default_StartSpeed - m_nSpeed) / m_nDeceleration)) {
			m_nPhase = Phase_Decel;
		}
		break;
	case Phase_Decel:
		m_nSpeed += m_nDeceleration;
		if (Default_StartSpeed <= m_nSpeed) {
			m_nSpeed = Default_StartSpeed;
			m_nPhase = Phase_Stop;
		}
		PWMGenPeriodSet(Base, Generator, m_nSpeed);
		PWMPulseWidthSet(Base, PWM_OUT_2, 64);
		PWMGenEnable(Base, Generator);
		break;
	case Phase_Stop:
		PWMGenDisable(Base, Generator);
		break;
	default:
		break;
	}
}
示例#19
0
文件: ymuart1.c 项目: ilabmp/micro
void Init_PWM() {
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
	SysCtlPWMClockSet(SYSCTL_PWMDIV_2);
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0);
	PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400);
	PWMGenEnable(PWM_BASE, PWM_GEN_0);
	PWMOutputState(PWM_BASE, PWM_OUT_0_BIT, true);
}
示例#20
0
文件: ming.c 项目: ilabmp/micro
void Init_PWM() {
	//PWM
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM); //Will use PWM
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0); // change GPIO port F, pin 0 as PWM0
	PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN); //Create PWM gen 0
	PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 402); // Set the period for PWM Generator0
	PWMGenEnable(PWM_BASE, PWM_GEN_0); // Enable the PWM Generator0
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 1); //Set PWM width
	PWMOutputState(PWM_BASE, PWM_OUT_0_BIT, true);
}
示例#21
0
void manualSetup(void)
{
	led = 0;
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, led);

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
	SysCtlPWMClockSet(SYSCTL_PWMDIV_64);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);


	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2);
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_3);
	GPIOPinConfigure(GPIO_PF1_M1PWM5);
	GPIOPinConfigure(GPIO_PF2_M1PWM6);
	GPIOPinConfigure(GPIO_PF3_M1PWM7);

	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
	GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

	ui32PWMClock = SysCtlClockGet() / 64;
	ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
	PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ui32Load);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ui32Load);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui8Adjust_red * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_2);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, ui8Adjust_blue * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_6_BIT, true);

	PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, ui8Adjust_green * ui32Load / 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_7_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_3);
}
void pwmInit(void) {
	SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_1);
	GPIOPinConfigure(GPIO_PD1_M1PWM1);
	PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
	PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, 1000);
	PWMOutputState(PWM1_BASE, PWM_OUT_1_BIT, true);
	PWMGenEnable(PWM1_BASE, PWM_GEN_0);
}
示例#23
0
文件: Base.c 项目: ilabmp/micro
void Init_PWM() {
	//PWM 0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM); //PWM Device Set
	SysCtlPWMClockSet(SYSCTL_PWMDIV_2); // PWM Generation clock Set
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //Enable the GPIO port F
	GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0); // GPIO port F, pin 0 a PWM0
	PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN); // Configuration the PWM gen0
	PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400); // Set the Period of the PWM Generator0
	PWMGenEnable(PWM_BASE, PWM_GEN_0); // Enable the PWM Generator0
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 399); //Set PWM width
	PWMOutputState(PWM_BASE, PWM_OUT_0_BIT, true); //Start PWM

	//PWM 2
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Enable the GPIO port B
	GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_0); // GPIO port B, pin 0 a PWM2
	PWMGenConfigure(PWM_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN); // Configuration the PWM gen0
	PWMGenPeriodSet(PWM_BASE, PWM_GEN_1, 400); // Set the Period of the PWM Generator0
	PWMGenEnable(PWM_BASE, PWM_GEN_1); // Enable the PWM Generator0
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_2, 399); //Set PWM width
	PWMOutputState(PWM_BASE, PWM_OUT_2_BIT, true); //Start PWM

}
示例#24
0
//*****************************************************************************
//
// This example demonstrates how to setup the PWM block to generate signals.
//
//*****************************************************************************
void F_PWM_init(void)
{
//!setting up PWN

    volatile unsigned long ulLoop;


    //
    // Set the clocking to run directly from the crystal.
    //

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    //
    // Enable the peripherals used by this example.
    //
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    //
    //! Set GPIO B0 and B1 as PWM pins.  They are used to output the PWM0 and
    //! PWM1 signals.
    //
    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	//
	//! Enable the PWM2 and PWM3 output signals if true.
	//
	PWMOutputState(PWM0_BASE,PWM_OUT_2_BIT|PWM_OUT_3_BIT, false);
	//
	//! Enable the PWM generator.
	//
	PWMGenEnable(PWM0_BASE, PWM_GEN_1);

    //
    //! Compute the PWM period based on the system clock.
    //
    ulPeriod = SysCtlClockGet() / PWMperiedset;

    //
    // Set the PWM2 period
    //
    PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_DBG_RUN);
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, ulPeriod);
}
示例#25
0
文件: motor.c 项目: eeshanl/ee472
//this initializes the speaker on the Stellaris board. 
//Speaker is hooked up to PWM0 
void speakerInit(){
  //enable the speaker peripheral that is connected to PWM0 
  SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
  //Set GPIO Port: G Enabled
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
  //Tell Port G, Pin 1, to take input from PWM 0
  GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);
  //Set a 4400 Hz frequency as u1Period
  ulPeriod = SysCtlClockGet() / (4440);
  //Configure PWM0 in up-down count mode, no sync to clock
  PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
  PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
  //Set u1Period (4400 Hz) as the period of PWM0
  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);
  //Set PWM0, output 1 to a duty cycle of 1/8
  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, ulPeriod / 16);
  //Activate PWM0
  PWMGenEnable(PWM0_BASE, PWM_GEN_0);
}
示例#26
0
文件: bsp.c 项目: saiyn/web
void bsp_pwm0_init(void)
{
	/*Enable device*/
  SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
	/*Set clock divider*/
  PWMClockSet(PWM0_BASE,PWM_SYSCLK_DIV_64);
	/*Enable PWM pin*/
  GPIOPinConfigure(LCD_PWM_CHANNEL);
  GPIOPinTypePWM(LCD_PWM_PORT, LCD_PWM_PIN);
	/*Configure PWM generator*/
  PWMGenConfigure(PWM0_BASE, PWM_GEN_0,(PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC));
	/*Set PWM timer period*/
  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0,gSysClock/10000);
	/*Set width for PWM0*/
  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 50*PWMGenPeriodGet(PWM0_BASE,PWM_GEN_0)/100);
	/*Enable output*/
  PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, 0);
  /*Enable Generator*/
  PWMGenEnable(PWM0_BASE, PWM_GEN_0);
}
示例#27
0
文件: bsp.c 项目: saiyn/web
void bsp_pwm_for_sense_init(void)
{
  /*Enable device*/
  SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
  /*Set clock divider*/
  PWMClockSet(PWM0_BASE,PWM_SYSCLK_DIV_1);  
  /*Enable PWM pin*/
  GPIOPinConfigure(GPIO_PK5_M0PWM7);
  GPIOPinTypePWM(SENSE_THRES_PORT, SENSE_THRES_PIN);
  /*Configure PWM generator*/
  PWMGenConfigure(PWM0_BASE, PWM_GEN_3,(PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC));
  /*Set PWM timer period*/
  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3,gSysClock/1000000);   
  /*Set width for PWM0*/
  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_7, 1*PWMGenPeriodGet(PWM0_BASE,PWM_GEN_3)/5);
  /*ensable output*/
  PWMOutputState(PWM0_BASE, PWM_OUT_7_BIT, 1);
  /*Enable Generator*/
  PWMGenEnable(PWM0_BASE, PWM_GEN_3);
	
}
示例#28
0
//*****************************************************************************
//
// This example demonstrates how to setup the PWM block to generate signals.
//
//*****************************************************************************
void motor_init(void)
{
//!setting up PWN

    volatile unsigned long ulLoop;

    //
    // Set the clocking to run directly from the crystal.
    //

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    //
    // Enable the peripherals used by this example.
    //
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    //! Set GPIO F0 and D1 as PWM pins.  They are used to output the PWM0 and
    //! PWM1 signals.
    //
    GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0);
    GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_1);
	//
	//! Enable the PWM0 and PWM1 output signals if true.
	//
	PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false);
	//
	//! Enable the PWM generator.
	//
	PWMGenEnable(PWM0_BASE, PWM_GEN_0);

	//
	//! Loop forever while the PWM signals are generated.
	//
}
示例#29
0
static void TisA(void){
	// Method to check determine when the alarm will activate
	// If all digits of the clock are equal, we activate
	if (m1==am1){
		if (m2==am2){
			if (h1==ah1){
				if (h2==ah2){
					if (ampm==aampm){
						// Turn on the LED
						GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_0);
						// Turn on the alarm
						PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);
						PWMGenEnable(PWM0_BASE, PWM_GEN_0);
						// Display text on screen
						RIT128x96x4StringDraw("WAKE UP!", 40, 10, 15);
						// Enable the interrupt so we can turn off the alarm
						// or use the snooze button
						GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);
					}
				}
			}
		}
	}
}
示例#30
0
文件: Functions.c 项目: suix2/InUW
void SolarPanel(void *vParameters)
{
  
  static unsigned short motorDrive = 0;
  unsigned long period = 125000;
  static Bool Flag = FALSE;
  static unsigned long dutyCycle = 62500;
  static int remainingDeployment = 1000;
  
  while(1)
  {
    solarPanel * myPanel = (solarPanel*) vParameters;
  // DEREREFWEJFIOEAWN DEREFERENCE POINTERS
  
  //IntEnable(INT_GPIOB);

//  SysCtlPWMClockSet(SYSCTL_PWMDIV_32);
//  if (*(myPanel->solarPanelRetract))
//  {  
//    remainingDeployment = 0;
//  }
//  else{ 
//    remainingDeployment = 1000;
  // 100% motor drive * 10 seconds
  
//  
//  char temp[20];
//  sprintf(temp,"%u",*(myPanel->solarPanelDeploy));
//  RIT128x96x4StringDraw(temp, 40, 80, 15);
//  sprintf(temp,"%u",*myPanel->solarPanelRetract);
//  RIT128x96x4StringDraw(temp, 60, 80, 15);
//    sprintf(temp,"%u",remainingDeployment);
//  RIT128x96x4StringDraw(temp, 80, 80, 15);
  

  if(!((*(myPanel -> solarPanelDeploy) && 0 == remainingDeployment) && 
       (*(myPanel -> solarPanelRetract) && 1000 == remainingDeployment)))
    {
    if(*myPanel->solarPanelDeploy || *myPanel->solarPanelRetract)
    {
    
      SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);

      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
     
      GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);
      
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);
      
      GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0);
      
      GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
      
      PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
      
      PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, period);

      PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, dutyCycle);

      PWMGenEnable(PWM0_BASE, PWM_GEN_0);
      
      PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, 1);
    }
    if(*(myPanel -> driveMotorSpeedInc))
      {
        if((dutyCycle + (0.05 * period)) < period)     // ensures duty cycle does not exceed 100%
        {
          dutyCycle += (period * 0.05); // Increments motor speed by 5%
        } 
        (*(myPanel -> driveMotorSpeedInc)) = FALSE;
      }
    else if(*(myPanel -> driveMotorSpeedDec))
      {
        int limit = dutyCycle - (0.05 * period);
        if(limit > 0)          // ensures duty cycle does not drop below 0%
        {
          dutyCycle -= (period * 0.05); // Decrements motor speed by 5%
        }
        (*(myPanel -> driveMotorSpeedDec)) = FALSE;
      }
    
    motorDrive = dutyCycle * 100 / period; // (dutyCycle / period) * 100% / 10
                                          // iterations per second 
                                          // solar panels are set up such that
                                          // 10 seconds of 100% motorDrive will 
                                          // fully retract or detract a solar panel
                                          // from a full ON or OFF state respectively
    if(*(myPanel -> solarPanelDeploy))
      {
        if((remainingDeployment - motorDrive) < 0)
        {
          remainingDeployment = 0;
        }
        else 
        {
          remainingDeployment -= motorDrive;
        }
      } 
    else if(*(myPanel->solarPanelRetract))
      {
        if((remainingDeployment + motorDrive) > 1000)
        {
          remainingDeployment = 1000;
        }
        else
        {
          remainingDeployment += motorDrive;
        }
      }
    
    if(remainingDeployment == 0 && *(myPanel -> solarPanelDeploy))
      {
        *(myPanel -> solarPanelDeploy) = FALSE;
        *(myPanel -> solarPanelState) = TRUE;
        g_ulGPIOb=1;
        PWMGenDisable(PWM0_BASE, PWM_GEN_0);
        PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, 0);
      }
    else if(remainingDeployment == 1000)
    {
      if(*(myPanel -> solarPanelRetract))
      {
        *(myPanel -> solarPanelRetract) = FALSE;
        *(myPanel -> solarPanelState) = FALSE;
        g_ulGPIOb=1;
        PWMGenDisable(PWM0_BASE, PWM_GEN_0);
        PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, 0);
      }
    }
    }
    vTaskDelay(500);
  }
}