7 Replies Latest reply on Oct 16, 2015 5:40 AM by JoMe_264151

    Interrupt - Help

      Hi, I am getting some warnings in my code. It is due to an interrupt routine -


      This is the warning - MULTIPLE CALL TO FUNCTION.  I found out that I should create a reentrant file -  but I am not sure how to create one and what it should contain.


      Best Regards ;)

        • 1. Re: Interrupt - Help

          This error message pops up when you have got a routine that is called


          a) from within an interrupt handler




          b) from any other place in your project.


          All will be well if you can avoid a) or b)


          To make a reentrant function start reading here.





          • 2. Re: Interrupt - Help



            Okay, would a reentrant function solved my problem?

            • 3. Re: Interrupt - Help

              Short answer: Yes!


              Long answer: It is not your problem, it is a problem of the (old-fashioned) PSoC3 core 8051. This CPU has got a stack of only 256 bytes depth and there are a lot of provisions taken by Keil to have C-compiler generated code running flawlessly. To be quite honest I (personally) would suggest to start working with one of the more modern cores as PSoC5 with ARM M3 or PSoC4 with an M0 core.


              Your above problem and others you have not come to yet do not exist in ARM cores.


              Easiest door to the ARM - world:


              CY8CKit-044 PSoC 4-M Pioneer development kit and the CY8CKit-059 the PSoC 5 prototyping kit.





              1 of 1 people found this helpful
              • 4. Re: Interrupt - Help

                Ok. I would definitely consider buying a Psoc5 (for future projects).


                I have now used a re-entrant fill and I have been able to reduce the warnings from 13 til 6.


                I have no idea- why the last 6 warnings are there. I have attached my code. 


                Best regards.  

                • 5. Re: Interrupt - Help

                  You have to distinguish between your own function and generated code.


                  The former need a "reentrant" after their definition and declaration, the latter have to be put into the .cyre-file.


                  Your general problem is your program structure it looks like you try to handle everything within your interrupt handler. This is not recommended. Better practice is


                  In interrupt handler set a global (volatile!) flag to indicate the situation and reset the interrupt cause.


                  In main loop check for flag, if set, reset flag and act accordingly.




                  You have got many global variables in your functionner.c. Good practice is to declare those as "static" which will reduce the scope to this file only.





                  1 of 1 people found this helpful
                  • 6. Re: Interrupt - Help

                    Hi Bob..


                    I now check for a flag in my main - and surprisingly the warnings are gone . Thanks for that


                    unfortunately new problems has arise.


                    plccom - (which is here the where interrupt flag is used) doesn't work and when my other functions in main also are


                    initialized (like udlejning and initservercommunication)... It is like my code gets stuck here. 


                    I have absolutely no ideas - why this is happening.


                    By the way I am also getting this warning 'returning': recursive call to non-reentrant function  


                    The code is detached.


                    Best regards. 

                    • 7. Re: Interrupt - Help

                      When you compile and inspect the notes thoroughly you are hinted to the place of the warnings or you get names to search for in your code.


                      You have got a call to a function within the function (recursion)  When the function is declared as reentrant that will work, but I still question if that is wanted.