3 Replies Latest reply on Nov 18, 2019 2:02 AM by gisc_1091076

    Interrupt blocked PsoC5 !

    gisc_1091076

      Hello,

      I have a problems with the interrupts with psoc5. When i start  the interrupts, after a casual time this interrupts are blocked. Can you help me ? it's urgent! Thanks

       

      I have setted the block this:

      Resolution: 8-bit

      Implemetation.fixed function

      Period:100ms

      Capture mode:none

      Enable mode:Software only

      Run mode: Continuos

      Interrupts: On TC

      Immagine1.png

       

      I have initialized the interrupts this :

            // Start Global Interrupt

           CYGlobalIntEnable ;

         

          CyDelay ( TIME_5_MS ) ;

         

          /* Start components Interrupt */

          isr_I2C_rd_tmr_StartEx ( isr_I2C_rd_tmr_Interrupt ) ;

       

            // Avvio l'interrupt per leggere l'I2C

          isr_I2C_rd_tmr_Start ( ) ;    // Start ISR

          // ... e il timer per la lettura del i2C

          I2C_Reader_Timer_Start ( ) ;

         

          isr_I2C_rd_tmr_Enable ( ) ;

       

      Functions interrupts :

      CY_ISR(isr_I2C_rd_tmr_Interrupt)

      {

          #ifdef isr_I2C_rd_tmr_INTERRUPT_INTERRUPT_CALLBACK

              isr_I2C_rd_tmr_Interrupt_InterruptCallback();

          #endif /* isr_I2C_rd_tmr_INTERRUPT_INTERRUPT_CALLBACK */

       

       

          /*  Place your Interrupt code here. */

          /* `#START isr_I2C_rd_tmr_Interrupt` */

          // Leggo lo stato del timer      

          I2C_Reader_Timer_ReadStatusRegister ( ) ; 

         

           // Cancello interrupt pendenti

          // isr_I2C_rd_tmr_ClearPending ( ) ;

         

          #ifdef DEBUG_ON       

          count ++ ;

          // Visualizzo il debug solamente una volta                                   

          printf ( "T:%i\r\n" , count ) ;

          #endif  

              /* `#END` */

      }

        • 1. Re: Interrupt blocked PsoC5 !
          LePo_1062026

          gisc,

           

          I'll make a first attempt to address your question.  If my suggestion is not successful, I may ask for a copy of your project to try to reproduce the issue.

           

          I noticed something in the code you included.  You have a printf() statement within the Interrupt Service Request (ISR).  This is basically not a good idea.  The printf() function is potentially a blocking function.  This means that to print your debugging information, you may be stuck in the interrupt with all other interrupts blocked until the printf() is completed and you return from the isr_I2C_rd_tmr_Interrupt() ISR.

           

          Since this is a debugging code line, comment it out.   Connect an PSoC pin configured as an output on the interrupt line.  See pic.

          Connect an oscilloscope to the Pin_ISR_mon.  You should see a positive pulse every time an ISR is requested.  This is a good HW debugging mode to replace your printf() with no performance impact on your running code.

           

          Len

          • 2. Re: Interrupt blocked PsoC5 !
            MoTa_728816

            Hi,

             

            I also tried with CY8CKIT-059, and found that

            "isr_I2C_rd_tmr_Interrupt" is defined in the auto generated function in "isr_I2C_rd_tmr.c".

            And you were calling both

                isr_I2C_rd_tmr_StartEx ( isr_I2C_rd_tmr_Interrupt ) ;

            and

                isr_I2C_rd_tmr_Start ( ) ;    // Start ISR

            Which I don't think good idea.

             

            So I created following project to test

             

            schematic

            001-schematic.JPG

            Pins

            002-Pins.JPG

            main.c

            ==============

            #include "project.h"

            #include "stdio.h"

             

            volatile uint32_t count = 0 ;

             

            #define STR_LEN 64

            char str[STR_LEN+1] ;

            void print(char *str)

            {

                UART_PutString(str) ;

            }

             

            void cls(void)

            {

                print("\033c") ; /* reset */

                CyDelay(100) ;

                print("\033[2J") ; /* clear screen */

                CyDelay(100) ;

            }

             

            void splash(void)

            {

                cls() ;

                print("PSoC 5LP Interrupt Test ") ;

                snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

                print(str) ;

            }

             

            CY_ISR(my_I2C_Timer_isr)

            {

                I2C_Reader_Timer_ReadStatusRegister() ;

                count++ ;

            }

             

            void init_hardware(void)

            {

                UART_Start() ;

             

                /* Start components Interrupt */

                isr_I2C_rd_tmr_StartEx ( my_I2C_Timer_isr ) ;

               

                I2C_Reader_Timer_Start() ;

               

                CyGlobalIntEnable; /* Enable global interrupts. */

            }

             

            int main(void)

            {

                uint32_t prev_count = 0 ;

               

                init_hardware() ;

               

                splash() ;

               

                for(;;)

                {

                    if (prev_count != count) {

                        prev_count = count ;

                        snprintf(str, STR_LEN, "count = %d\n", prev_count) ;

                        print(str) ;

                    }

                }

            }

            ==============

             

            Tera Tem log

            (at start)

            000-TeraTerm-log.JPG

            (current (while I'm typing this))

            003-TearTerm-log2.JPG

            So far, working.

             

            moto

            1 of 1 people found this helpful
            • 3. Re: Interrupt blocked PsoC5 !
              gisc_1091076

              Thanks you , i have resolved the my problem.