Other Parts Discussed in Thread: EK-TM4C123GXL, TM4C123GH6PM
Hello.
I know that are already a few posts regarding this problem but solutions from those are not working for me.
I am using TIVA LaunchPad (EK-TM4C123GXL), and my code is a modified lab 15 from LaunchPad workshop:
#include "inc/tm4c123gh6pm.h"
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#define PWM_FREQUENCY 55
int main(void)
{
volatile uint32_t ui32Load;
volatile uint32_t ui32PWMClock;
volatile uint32_t ui32Adjust;
ui32Adjust = 500;
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1);
ROM_GPIOPinConfigure(GPIO_PF1_M1PWM5);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
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;
ROM_GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_4|GPIO_PIN_0, GPIO_DIR_MODE_IN);
ROM_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);
ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui32Adjust * ui32Load / 1000);
ROM_PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT, true);
ROM_PWMGenEnable(PWM1_BASE, PWM_GEN_2);
PWMIntEnable(PWM1_BASE, PWM_INT_GEN_2);
IntEnable(INT_PWM1_2);
PWMGenIntTrigEnable(PWM1_BASE, PWM_INT_GEN_2, PWM_INT_CNT_ZERO);
IntMasterEnable();
while(1)
{
if ((ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x00) && (ui32Adjust > 10 ))
{
ui32Adjust--;
ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui32Adjust * ui32Load / 1000);
}
if ((ROM_GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0x00) && (ui32Adjust < 900))
{
ui32Adjust++;
ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ui32Adjust * ui32Load / 1000);
}
SysCtlDelay(100000);
}
}
void PWM1Gen2IntHandler(void)
{
PWMGenIntClear(PWM1_BASE, PWM_INT_GEN_2, PWM_INT_CNT_ZERO);
if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_3))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x8);
}
}
As you can see, the difference from the LaunchPad Workshop Lab15 is that I am modifying the intensity of the Red LED. This parts works.
But I have also an interrupt on that PWM which does not execute: more, the code execution does not hang into IntDefaultHandler()'s forever loop. This interrupt just does not come.
Any ideas?