4 Replies Latest reply on May 25, 2011 11:44 PM by gautamd_

    PWM Overflow Interrupt


      I have set up a PWM module running at 40khz, and wired the interrupt output to an ISR as shown in the attached file.


      The problem is that execution nevert reaches the interrupt handler...


      I have called the initialisation functions for the PWM module and I know that the PWM is up and running fine. I have also called <ISR>_Start() which internally calls <ISR>_Enable... Did a single step debug to ensure that these functions are indeed called. The PWM is working fine since I have checked it on a 'scope. Cant figure out what I'm missing... Also, what is to be expected if I tie the Interrupt output of the PWM Block to a digital output pin?



        • 1. Re: PWM Overflow Interrupt

          Hey Abhijit,




          Can you please tell us on what event you want an Interrupt to be triggered?


          Whether you want Interrupt on Terminal Count or on Compare 1 Event? According to your requirement, you can choose any of these. It can be seen in the Advanced tab as shown below.










          In main( ), don't forget to uncomment the CYGlobalIntEnable. Else Interrupt will never be triggered.




          In the isr.c, include the PWM0.h and all other header files which you'll be using in the ISR vector. These should be written inside the #START and #END statements. Any other variables can also be declared here. If they are used in main too, then use the keyword "extern".









          In the CY_ISR( ) function read the status register to clear the interrupt bit as it is sticky. Then you can set variables according to your logic.











          This can get your Interrupt to working. Let us know if this helps.

          • 2. Re: PWM Overflow Interrupt

            Oh dang! I was missing just the global interrupt enable statement... "CYGlobalIntEnable". Working now.


            BTW It was not there in the default generated main(). It'd be a good idea if the datasheets for the components with interrupts mentioned this...





            • 3. Re: PWM Overflow Interrupt



              I feel that a lot of small things need to be added to the datasheet; for example NONE of the datasheets mention that PWM0_ReadStatusRegister(); must be called to get the PWM interrupt ready for the next time. In the datasheet for the ISR there is but one vague reference -


              "Some interrupt sources will also need to be cleared with the appropriate block API (GPIO, UART, …) or they will just re-pend the interrupt. Entering the ISR will clear the pending bit for some interrupt sources."


              @Cypress folks - I believe some effort is needed to make datasheets a bit more comprehensive in covering all these small nuggets of info!



              • 4. Re: PWM Overflow Interrupt

                Hi Abhijit,




                Thank you very much for the feedback.


                The use of 'ReadStatus Register( )' to clear interrupts is mentioned in the Component datasheet rather than in device datasheet.


                "The interrupt output is the logical OR of the group of possible interrupt sources. This
                signal will go high while any of the enabled interrupt sources are true. The interrupt output
                shall remain asserted until the Status Register is read out by the software. In order to
                receive subsequent interrupts, the interrupt shall be cleared by reading the Status
                Register using the PWM_ReadStatusRegister() API. The interrupt output is not visible if
                the Use Interrupt parameter is not set. This allows the status register to be removed for
                resource optimization as necessary."