10 Replies Latest reply on Feb 20, 2015 3:06 AM by user_1377889

    Software interrupt

    yonkou.claire

      Hello everyone,

         

      i would like to execute a part of my code just once and i was thinking about using software interrupt.

         

      can someone tell me how to configre it?

         

      Thanks for any help

         

      Regards

         

      Claire

        • 1. Re: Software interrupt
          user_1377889

          A software interrupt is raised by a software instruction. This usually comes in handy to expose an interface of an RTOS to some  processes. For a normal project it would be easier to just "Call" the appropiate function which additionally has the advantage that parameters can be specified and a return-value can be given back.

             

           

             

          Bob

          • 2. Re: Software interrupt
            user_14586677

            Claire, tell me what you are trying to accomplish -

               

             

               

            1) What will you use to trigger the ISR

               

            2) What the ISR has to do

               

            3) Is it a one time only ISR or a periodic one ?

               

            4) Why is it software only ?

               

             

               

            Regards, Dana.

            • 3. Re: Software interrupt
              yonkou.claire

              Hello Dana,

                 

              1) What will you use to trigger the ISR

                 

              2) What the ISR has to do

                 

              3) Is it a one time only ISR or a periodic one ?

                 

              4) Why is it software only ?

                 

              i am reading an ADC value, with whom i produce a PWM. I would like to produce after first read of ADC value, a PWM with double frequency, whose frequency i want to decrease until it is no longer double, and then continue the program without double the frequency anymore.

                 

              I would like to use the first read of ADC value as a trigger, the decrease of PWM frequency as the ISR (which will be perform only once)

                 

              I thought it has to be software only because it is after reading the ADC value that i want to use the ISR to decrease the double frequency.

                 

               

                 

              Thanks for replying

                 

              Regards

                 

              Rosine

              • 4. Re: Software interrupt
                user_1377889

                Wouldn't it be easier to use in your PWM setting function a construct like

                   

                void SetPWM(uint16 ADCValue)

                   

                {

                   

                uint16 PWMCompare;

                   

                static uint8 FirstRead = FALSE;

                   

                    PWMCompare = ADCValue; // or any function value depending on ADCValue

                   

                    if(FirstRead)

                   

                    {

                   

                        PWMCompare /= 2;

                   

                        PWMRead = TRUE;

                   

                    }

                   

                    PWM_WriteCompare(PWMCompare);

                   

                }

                   

                 

                   

                under the assumption that you want to modify the pulse-width and not the frequency

                   

                 

                   

                Happy coding

                   

                Bob

                • 5. Re: Software interrupt
                  yonkou.claire

                  Hello Bob,

                     

                  thanks for replying. I got this idea too, but the problem is, that by doing so, the execution of the program become very slow.

                     

                  Regards

                     

                  Rosine

                  • 6. Re: Software interrupt
                    user_1377889

                    An interrupt will consume quite more time, since the actual processor status has to be saved on stack and later retrieved. On the other hand will your PWM consume some time for one period which usually is quite long compared to the execution time needed to check and branch on a local variable. Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
                    Creator->File->Create Workspace Bundle (minimal)
                    and attach the resulting file.



                    Bob
                     

                       

                    PS: Must leave, will be back 19:00h Local Time Bremen

                    • 7. Re: Software interrupt
                      yonkou.claire

                      Hello Bob,

                         

                      the problem is solved. Thanks any way.

                         

                      Regards

                         

                      Rosine

                      • 8. Re: Software interrupt
                        user_1377889

                        Just for curiosity: How did you solve your problem and what did you change?

                           

                         

                           

                        Bob

                           

                        PS: Where are you located in Germany??

                        • 9. Re: Software interrupt
                          yonkou.claire

                          i just wanted to know how to create a software interrupt.

                             

                          by applying a control register to an interrupt(UDB) and using the interrupt pending function in the main function, the software interrupt is created.

                             

                          i am arround  Hamburg.

                             

                          Regards

                             

                          Rosine

                          • 10. Re: Software interrupt
                            user_1377889

                            Easiest is to use an interrupt component and after initialization use the Isr_SetPending() API.

                               

                             

                               

                            Bob

                               

                            PS Are you planning to visit Cypress at "embedded world" in Nürnberg next week? It has always been very informative to talk to the Cypress staff there.