I did some digging of my own since I wasn't getting any answers any time soon. I found the solution to generate and run the interrupt smoothly. I hope this thread helps someone who's having same trouble as me.
Using interrupt with the PWM.
- Set the PWM based on which the interrupt needs to be generated. Ex: Val 0/1/2/3/4/5. Here, PWMA defines the PWM where the interrupt needs to be generated. Select the module in the PWM and select the triggering point.
soaring_sun_0-1613032025065.png
- Enable the interrupt using the already defined function. Within the parenthesis, define which is the trigger selection. Since in the above example val0 is selected, hence here it is CMP0. A NVIC priority can also be set to this, but it depends on the user and it is not mandatory.
soaring_sun_1-1613032025072.png
- Write the function with the corresponding heading of the interrupt handler where the instructions need to be called every time the interrupt occurs.
soaring_sun_2-1613032025088.png
- Once the ISR function is written, it is important to clear the interrupt flag. For this a function called, “clear status flag” can be used where both the corresponding status and error flag are reset.
soaring_sun_3-1613032025096.png
If I have missed out something or if there is more, you are more than welcome to correct me. Let me know if I have been making mistake all this while...