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.
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.:
// 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?
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.
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?
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.
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?
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.
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!