I need to interrupt every 10ms when the PWM counter is empty (I'm counting down). I have Tiva c series TM4C123G. Can not get to the interrupt handler.
Thank you for your solution.
Here is the code:
#define PWM_FREQUENCY 100
unsigned int arg_sinus_dt=0;
void PWM1IntHandler(void)
{
PWMGenIntClear(PWM1_BASE,PWM_GEN_0,PWM_INT_CNT_ZERO);
arg_sinus_dt=arg_sinus_dt+1;
}
int main(void) {
volatile unsigned int max;
volatile unsigned char compare;
compare = 83;
SysCtlClockSet (SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0);
GPIOPinConfigure(GPIO_PD0_M1PWM0);
PWMClock =sysCtlClockGet() / 64;
max = (PWMClock / PWM_FREQUENCY) - 1;
PWMGenConfigure(PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN);
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, max);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_0, compare * max / 1000);
PWMOutputState(PWM1_BASE, PWM_OUT_0_BIT, true);
PWMGenEnable(PWM1_BASE, PWM_GEN_0);
is this correct?
PWMIntEnable(PWM1_BASE, PWM_GEN_0);
PWMGenIntTrigEnable(PWM1_BASE, PWM_GEN_0, PWM_INT_CNT_ZERO);
while(1){}
}
The've defined the vector table in startup_ccs.c PWM1IntHandler (PWM1 Generator 0)and also the function extern void PWM1IntHandler (void).