8 Replies Latest reply on Jun 3, 2019 2:00 AM by EnSi_1099366

    How can I assign a custom default ISR in PSoC Creator?

    EnSi_1099366

      Hi,

       

      I am new with PSoC.

      I need to put code into a default ISR for a PSoC-5LP.
      I did not find the macro to reassign it properly (or the related documentation), because all the ISR used are in the GUI, and therefore an API is generated. But what about the default vector? Can I manipulate the link of the interrupt manually? Is it safe given the interactions with PSoC Creator? If so, how can I do it?

       

      I believe it is a silly questions, but I miss whereto look for this info.

       

      Thank you,

        • 1. Re: How can I assign a custom default ISR in PSoC Creator?
          JoMe_264151

          Of course you may change an interrupt vector for your own needs. Have a look into the "System Reference Guide" for your PSoC 4 or 5. There are several APIs to access the ICU.

           

          Bob

          • 2. Re: How can I assign a custom default ISR in PSoC Creator?
            EnSi_1099366

            The only thing that I see in the System Reference Guide related to this is the:

             

            cyisraddress CyIntSetVector(uint8 number, cyisraddress address)

             

            which requires me to know all the numbers of the non used interrupts and assign them to the given address. Doing this seems too tedious, as I have to go through the cyfitter.h and CyLib.h manually to get to know that.

            Because of that,  I assume I overlooked something. For example, in AVR devices (Microchip), the GCC compiler knows the unused interrupts and assign them to a pre-defined location. If I want to change that, I rewrite such address in the table by calling a macro, i.e.:

             

            ISR(BADISR_vect)

            {

               // user code here

            }

             

            In the PSoC I know the mechanism is a bit more complex, but I expect there is a way to automatically assign the all unused interrupts to some location.
            Is not that I want to allocate some ISR to the default, but have a mean of safely doing this for all un-used interrupt, like the GCC is doing.

             

            What am I missing?

            • 3. Re: How can I assign a custom default ISR in PSoC Creator?
              JoMe_264151

              In the .dwr view is an "Interrupt" tab at the bottom side. There you can see which interrupts are already taken by your design. Take an unused number for your vector.

               

              Bob

              • 4. Re: How can I assign a custom default ISR in PSoC Creator?
                EnSi_1099366

                So, I am taking one of my auto generated assignments and are like this:

                 

                void IRQ_SD_SetVector(cyisraddress address)

                {

                    cyisraddress * ramVectorTable;

                 

                    ramVectorTable = (cyisraddress *) *CYINT_VECT_TABLE;

                 

                    ramVectorTable[CYINT_IRQ_BASE + (uint32)IRQ_SD__INTC_NUMBER] = address;

                }

                 

                If I create a function that swipes all the unused interrupts to store my own default interrupt handler, the best way is to do something like this:

                 

                 

                ramVectorTable[CYINT_IRQ_BASE + (uint32)UNUSED_INTC_NUMBER_0] = (default isr address);

                ramVectorTable[CYINT_IRQ_BASE + (uint32)UNUSED_INTC_NUMBER_1] = (default isr address);

                ramVectorTable[CYINT_IRQ_BASE + (uint32)UNUSED_INTC_NUMBER_2] = (default isr address);

                ramVectorTable[CYINT_IRQ_BASE + (uint32)UNUSED_INTC_NUMBER_3] = (default isr address);

                 

                Or there is a way to automatically assign all the other IVT locations to my default isr address?

                 

                 

                • 5. Re: How can I assign a custom default ISR in PSoC Creator?
                  JoMe_264151

                  I do not see what exactly is the benefit of your unused interrupt setting.

                  An interrupt must be enabled to happen using CyEnableInts()

                  So the default situation will be: Unused interrupts cannot fire.

                   

                  Bob

                  • 6. Re: How can I assign a custom default ISR in PSoC Creator?
                    EnSi_1099366

                    I prefectly understand that unused interrupt cannot fire. But this is a bug counter measure, also against bit flips and other things, hence is a requirement in this project.

                     

                    If Cypress does not allow me to do this, I would go with the difficult way (like my example). In that case, what would be the best way to do it, then?

                    • 7. Re: How can I assign a custom default ISR in PSoC Creator?
                      JoMe_264151

                      I would try to check whether the interrupt vector contains zeroes and replace all of those with the address of your handler.

                      Additionally you should replace the handlers for hardware fault and NMI with your own ones.

                       

                      Bob

                      • 8. Re: How can I assign a custom default ISR in PSoC Creator?
                        EnSi_1099366

                        I actually discovered that Cypress support what I needed to do, without interfering with the autogeneration of the code.

                         

                        I just needed to define CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK in cyapicallbacks.h and using the CyBoot_IntDefaultHandler_Exception_EntryCallback() containing my default code in my own application code, so I get exactly what I want: a call to my default ISR when something unexpected happens.
                        By default is also added a while(1) but I can do something before a wrong ISR triggers, which is what I needed to do.

                         

                        So, I guess they thought the same as other MCU vendors, which makes perfectly sense: an unexpected ISR must be handled, at least with an infinite loop.

                         

                        Thanks in any case!