8 Replies Latest reply on Nov 11, 2013 10:02 AM by user_189850962

    Reading Interrupt Status Register (To clear active interrupt)

    user_189850962

      Hi All,

         

      im really struggeling clearing interrupt which is driven by PWM output (pwm).

         

      once the interrupt is driven, i cant clear it and it stays on (Clear Pending isnt working).

         

       

         

      Please help me..

         

      Thank you :)

        • 1. Re: Reading Interrupt Status Register (To clear active interrupt)
          user_14586677

          Several questions -

             

           

             

          1) What is the period of the PWM ?

             

          2) What does the code look like in ISR ? Normally you want to set a simple flag

             

          and exit, servicing ISR in main(). You especially do not want to call f()'s, that

             

          creates a lot of stack push and latency.

             

          3) What is the function of the ISR ? To do what ?

             

           

             

          Regards, Dana.

          • 2. Re: Reading Interrupt Status Register (To clear active interrupt)
            user_78878863

            Is your ISR level- or edge-triggered? If its level-triggered, it will re-trigger as long as the PWM output is high.

            • 4. Re: Reading Interrupt Status Register (To clear active interrupt)
              user_189850962

              First of all i would like to thank you all for the replies.

                 

               

                 

              Dana:

                 

              1. PWM Freq. is 2KHz

                 

              2+3. The code inside the ISR is only changing the value in some flag (uint8)

                 

              no function() calling inside or doing something complicated.

                 

               

                 

              Hli:

                 

              My ISR is RISING-EDGE triggred.

                 

               

                 

              Atached is the component connection and the code sinpest.

                 

               

                 

              Code:

                 

              CY_ISR_PROTO(CC_Battery_Tester_SM_1_1MSEC_IRQ)
              {
                  CC_Battery_Tester_SM_1_Pin_1_Write (onOFFFlag);
                  if (onOFFFlag == 1)
                  {
                      onOFFFlag = 0;
                  }else
                  {
                      onOFFFlag = 1;
                  }
                  CC_Battery_Tester_SM_1_ISR_1MSEC_ClearPending ();
              }

                 

               

                 

              Thank you all.

              • 5. Re: Reading Interrupt Status Register (To clear active interrupt)
                user_78878863

                The interrupts are cleared by calling the PWM_ReadStatusRegister() function (or PWM_1msec_ReadStatusRegister() in your case). _ClearPending only clear interrupts which have happened already but where the ISR has not been called yet (e.g. when interrupts are globally disabled). See also page 34 in the PWM datasheet.

                   

                Also, I think your function names are not right: the ISR component is called ISR_1MSEC, but you call e.g. CC_Battery_Tester_SM_1_ISR_1MSEC_ClearPending. I think this should be just ISR_1MSEC_ClearPending .

                • 6. Re: Reading Interrupt Status Register (To clear active interrupt)
                  user_189850962

                  Its working now!! :)

                     

                  Reason for why it didnt work for me:

                     

                  <HeaderFile.h>

                     

                  CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR);

                     

                   

                     

                  <CodeFile.c>
                  CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR) //Wrong Function name is Written: Should be only CY_ISR(`$INSTANCE_NAME`_1MSEC_ISR)
                  {
                      `$INSTANCE_NAME`_Pin_1_Write (onOFFFlag);
                      if (onOFFFlag == 1)
                      {
                          onOFFFlag = 0;
                      }else
                      {
                          onOFFFlag = 1;
                      }
                      `$INSTANCE_NAME`_ISR_1MSEC_ClearPending ();
                     
                      /* PSoC3 ES1, ES2 RTC ISR PATCH  */
                      #if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)
                          #if((CYDEV_CHIP_REV_EXPECT <= CYDEV_CHIP_REV_LEOPARD_ES2) && (`$INSTANCE_NAME`_ISR_1MSEC__ES2_PATCH ))     
                              `$INSTANCE_NAME`_1MSEC_ISR_ISR_PATCH();
                          #endif
                      #endif   
                  }

                     

                   

                     

                  Solution:

                     

                  <HeaderFile.h>

                     

                  CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR);

                     

                   

                     

                  <CodeFile.c>
                  CY_ISR(`$INSTANCE_NAME`_1MSEC_ISR)
                  {
                      `$INSTANCE_NAME`_Pin_1_Write (onOFFFlag);
                      if (onOFFFlag == 1)
                      {
                          onOFFFlag = 0;
                      }else
                      {
                          onOFFFlag = 1;
                      }
                      `$INSTANCE_NAME`_ISR_1MSEC_ClearPending ();
                     
                      /* PSoC3 ES1, ES2 RTC ISR PATCH  */
                      #if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)
                          #if((CYDEV_CHIP_REV_EXPECT <= CYDEV_CHIP_REV_LEOPARD_ES2) && (`$INSTANCE_NAME`_ISR_1MSEC__ES2_PATCH ))     
                              `$INSTANCE_NAME`_1MSEC_ISR_ISR_PATCH();
                          #endif
                      #endif   
                  }

                     

                   

                     

                  Again, Thank you all for your help :)

                  • 7. Re: Reading Interrupt Status Register (To clear active interrupt)
                    user_1377889

                    It looks as if you created your own component or did you make changes to the api-files from where the code is generated?

                       

                     

                       

                    Bob

                    • 8. Re: Reading Interrupt Status Register (To clear active interrupt)
                      user_189850962

                      I've made my own component and created my own interrupt.