I am using TWR-K60N512, with PK60DN512Z VMD10 chip. I'm trying to use the interrupt to update FTM0_C0V value when the FTM0 timer overflows but my program keeps getting suspended.
I have enabled the interrupt vector for FTM0, by adding this line "enable_irq(62);" in the main code. The interrupt vector assignment was found from Chapter 3 in the K60P144M100SF2RM reference manual. I have also enabled timer over flow interrupt 'FTM0_SC |= FTM_SC_TOIE_MASK;' .
This is what my ISR.h looks like:
#define __ISR_H 1
#define VECTOR_78 FTM0_isr
// ISR(s) are defined in your project directory.
extern void FTM0_isr(void);
This is what my interrupt function looks like, it is in the main source code. I have declared the function prototype in the main code too:
static unsigned short brightness = 0;
static bool increase = true;
if (FTM0_SC & 0x80) // if FTM counter exceeds MOD count.
if (brightness == 60000)
increase = false;
else if (brightness == 0)
increase = true;
FTM0_SC &= 0x7F; // clear TOF flag
FTM0_C0V = brightness;
FTM0_PWMLOAD |= FTM_PWMLOAD_LDOK_MASK;
My program was suspended whenever I run it and points to the following function in 'kinetis_sysinti.c' :
/* Write your interrupt code here ... */
Any idea how to troubleshoot this?