I am brand new to the launchpad (LM4F120) and trying to get PWM working. I am not using any of the functions defined in driverlib, I figured that I could simply follow the datasheet for the MCU and get the PWM with CCP working. However, that seems to not be the case. Any help getting my PWM working would be much appreciated.
#include <inc/lm4f120h5qr.h>
int main(void){
//Enable clock gating for GPIOF
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
int pin = 0x02; //0x02 is PF1, Red LED
//GPIO_PORTF_DIR_R = pin; //Don't care condition according to Table 10-3
GPIO_PORTF_DEN_R = pin;
//Set the alternate function of the selected GPIO and set the MUX
GPIO_PORTF_AFSEL_R = pin;
GPIO_PORTF_PCTL_R = GPIO_PCTL_PF1_T0CCP1;
//16/32-bit timer register clock gating control register
SYSCTL_RCGCTIMER_R = SYSCTL_RCGCTIMER_R0;
//Disable the timer
TIMER0_CTL_R = 0x0000;
//Set Timer 0 as a 16-bit timer
TIMER0_CFG_R = TIMER_CFG_16_BIT;
//Configure GPTM Timer Mode
TIMER0_TAMR_R = TIMER_TAMR_TAAMS | TIMER_TAMR_TAMR_PERIOD;
//Load the timer start value, the timer counts down
TIMER0_TAILR_R = 0xFFFF;
//Load the match value
TIMER0_TAMATCHR_R = 0x7FFF;
//Enable the timer
TIMER0_CTL_R = TIMER_CTL_TAEN;
//Loop forever
while(1){
}
}