7 Replies Latest reply on Apr 17, 2012 8:40 AM by MiKO_283856

    Freeing IOs




      I'm new to PSoC world, trying to improve m'y customer PSoC1 CY8C29466 design.


      The current dev is using a  zero cross detection done with a comparator which triggers a GPIO interrupt on every half cycle (Change From Read) of the 292Hz input sinusoidal signal.


      Such a routing is consumming one GPIO pin only for the purpose of linking the output of the comparator to tne input of the interrupt pin driver thru the out analog bus of the concerned column.


      Would there be another way to generate the interrupt without using the corresponding  pin as analog outputs are rare ressource? 





        • 1. Re: Freeing IOs

          Hi Michel,


          each of the 4 comparators provide a sole interrupt, have a look into the datasheet of your COMP-module. You have to use an API to enable the interrupt and then you do not need any pin.


          Are you familar with the (a bit complex) way to tell your PSoC to execute your interrupt-code?





          • 2. Re: Freeing IOs

            Hi Bob,


            This is really good news, gonna check this immediately, thanks for the information.


            The PSoC familly is very rich in terms of ressouces, so a lot to read before being proficient, this requires time...


            I'm familiar with interrupt sequences on other microcontroller brands, have already analysed how the PSoC1 Interrupt Controller works and how to manage the handler(s) so I don't think I'd be stuck on insoluble problems on this side.


            But if needed, will ask for.


            Best regards,



            • 3. Re: Freeing IOs

              So as I see you are not yet experienced in writing interrupt routines for PSoC1, it is (as I said) a bit complicated.


              Interrupt routines should be kept small to have a small latency, but for now I would prefer every simple but working solution.




              #pragma interrupt_handler MyIntRoutine




              void MyIntRoutine(void)




                  // All registers used in this routine are saved on the stack by the compiler


                  // Do NOT call delay-functions, don't wait for anything, no LCD-output


                  // Simplest is to set a flag and test for it in the main-loop


                  // When calling a function() within this interrupt-routine the compiler will generate additional code


                      // to save ALL REGISTERS on the stack at entry of the interrupt routine (~ 22 bytes)








              Edit the file "Boot.tpl" (you'll have to search for it in the pjoject folder). This file is a template (thus the .tpl) from which the "Boot.asm" is generated. The jump-table and its entries are clearly marked. insert at the appropiate plae a


              LJMP _MyIntRoutine    ; The unserscore (_) is needed!!!




              Happy coding



              • 4. Re: Freeing IOs

                 Well, I understand now why it was built with an IO.


                In fact the current design is using the legacy CMPPRG module which has no interrup capability.


                So I need to shift to the updated COMPZ and trigger its interrupt.


                Thx again for your answer, it helped.



                • 5. Re: Freeing IOs



                  My last post went before I read your advices.


                  I already know all this, I studied the customer code and many examples which are given thru the PSoC related web sites.


                  But this is a good review of how it works, again thanks for this valuable information.





                  • 6. Re: Freeing IOs

                    Might be, you misunderstood: You will have connect your comparator to the Comp-Bus. Then you may use the interrupt of the comp-bus





                    • 7. Re: Freeing IOs

                       OK Bob,


                      I'm lucky the output is already attached to the comp bus as I'm also using it to switch the sign of the rectifier module.