Tool/software: Code Composer Studio
I've been playing around with this launchpad kit and I've been able to set things up such that if I set up PB6 as a PWM and jump it to PF1, I'm able to control the brightness of the LED using an ADC channel and a pot. My question is, can I remove the extra work of setting up jumpers to those nodes and instead assume direct control with software? I've attempted to set up PF1, PF2, and PF3 as PWM channels the same way I did with PB6 but it does not seem to work. This is the function I used to set up the PWM Channels:
void UnlockPortF(void){
//Unlock all pins on Port F
GPIO_PORTF_LOCK_R=0x4C4F434B;
}
//Sets up PWM Module 1 for PWM5 (PF1 Red), PWM6(PF2 Blue), and PWM7(PF 3 Green)
void PWM_RGB_Init(void){
////////////////////////////////////////////////////////
//
// Enable the PWM1 peripheral
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
//
// Wait for the PWM1 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_PWM1))
{
}
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//
// Check if the peripheral access is enabled.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
{
}
void UnlockPortF(void);
// Configure the PWM generator for count down mode with immediate updates
// to the parameters.
//
//Configure PF outputs to PWM
GPIOPinConfigure(GPIO_PF1_M1PWM5);
GPIOPinConfigure(GPIO_PF2_M1PWM6);
GPIOPinConfigure(GPIO_PF3_M1PWM7);
//
GPIOPinTypePWM(GPIO_PORTF_BASE,GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
PWMGenConfigure(PWM1_BASE, PWM_GEN_2,
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenConfigure(PWM1_BASE, PWM_GEN_3,
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
//
// Set the period. For a 12.5 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_2, 1600);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, 1600);
//
// Set the pulse width of PWM0 for a 25% duty cycle.
//
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_2, 800);
//
// Set the pulse width of PWM1 for a 75% duty cycle.
//
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_3, 800);
//
// Start the timers in generator 0.
//
PWMGenEnable(PWM1_BASE, PWM_GEN_2);
PWMGenEnable(PWM1_BASE, PWM_GEN_3);
//
// Enable the outputs.
//
PWMOutputState(PWM1_BASE, (PWM_OUT_5_BIT | PWM_OUT_6_BIT|PWM_OUT_7_BIT), true);
/////////////////////////////////////////////////////////////////////
}
If anyone has any ideas what could be the problem I'd appreciate it.
Cheers,
Jim