Other Parts Discussed in Thread: EK-TM4C123GXL,
Hi all, I'm trying to write a simple program that will set the duty cycle to decrements of 10 every 1 second so Pin B0 will drive the LED in such a way it fades out and then returns to a 100% duty cycle once a 0% duty cycle is reached. Firstly, I'm just trying to drive the output pin to have a constant (40 %) duty cycle. However, everytime I make a call to PWMGenConfigure() I get a HardFault. Here's the code that initializes the PWM module using channel 0.
void initPWM() { SysCtlPWMClockSet(SYSCTL_PWMDIV_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB6_M0PWM0); GPIOPinTypePWM(GPIO_PORTB_BASE,GPIO_PIN_6); PWMGenConfigure(PWM0_BASE,PWM_GEN_0,PWM_GEN_MODE_DOWN); //set 1 lkHZ PWM frequency (16,000 / 16,000,0000) = 1 kHZ PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 160000); //set duty cycle to 40 % by loading in 6400 to PWM0CMPA. Every time we have had 6400 positive pulses in a frequency of 16,000, we will reset, meaning we were driving the pin high for 40% of the PWM period PWMPulseWidthSet(PWM0_BASE,PWM_OUT_0,6400 - 1); }