Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

Interrupts using the ARM core and the GIC

Altera_Forum
Honored Contributor II
2,306 Views

I have been looking at the Altera documentation for the GIC on the Cyclone V device. Found here: ftp://ftp.altera.com/up/pub/altera_material/15.0/tutorials/using_gic.pdf  

 

At the bottom of which (Appendix B) has some sample code. Does anyone know what the following is for:  

 

// Define the remaining exception handlers void __attribute__ ((interrupt)) __cs3_reset (void){ while(1); } void __attribute__ ((interrupt)) __cs3_isr_undef (void){ while(1); } void __attribute__ ((interrupt)) __cs3_isr_swi (void){ while(1); } void __attribute__ ((interrupt)) __cs3_isr_pabort (void){ while(1); } void __attribute__ ((interrupt)) __cs3_isr_dabort (void){ while(1); } void __attribute__ ((interrupt)) __cs3_isr_fiq (void){ while(1); }  

 

When I try to use the sample code it causes my program to get stuck in the __cs3_reset function. Obviously they're full of while(1); statements so the fact it gets stuck isn't that surprising, however I don't know why these are part of the 'complete code example' 

 

Any one got any ideas?  

 

Cheers
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
895 Views

All these __cs3_??? are the labels/names of Mentor's Code Sourcery interrupt/exception handlers. 

Code Sourcery is one of the variant of GCC for the ARM. 

 

That code is the interrupt/exception handlers themselves.
0 Kudos
Altera_Forum
Honored Contributor II
896 Views

Ooooppps, something went wrong. 

 

It's stuck in reset as this where the processor goes upon reset (reset is an exception). 

 

You may able to go into your "C" code by replacing the while(1) in void __attribute__ ((interrupt)) __cs3_reset (void) with this: 

extern void _start(void); 

_start() 

 

I'm not sure at all it will be OK as the stack hasn't been set-up. 

 

The other way is to simply comment out / remove the code for __cs3_reset. 

As it is defined, it most likely overloads the default one from the "C" library.
0 Kudos
ePiccolo-Engineering
795 Views

These are interrupt handler stubs. They do nothing as you can see - except when an interrupt is caught it gets into the infinite while(1).

If you pause the execution of the program via JTAG, and suppose you had an unhandled interrupt - it will be caught in the stub so that you can see it. 

If these interrupts were not installed, at least in the gcc toolchain version you have these stubs defined as 'weak' in a library - meaning that they would be used only if the user did not supply any other function. They still do an infinite loop though, but this time in assembly and it's a bit more difficult to understand where you crashed. 

So, for your question, these prototype function definitions are there for programming / debugging convenience. 

The reset handler should really not be written like this but rather perform basic runtime initialization of the processor and pass control to main(). you need to remove the __cs3_reset implementation above and try to compile again. If your project was setup correctly you should have a reset vector implementation prepared for you in assembly. 

 

Good luck with your embedded design

Guy Shemesh 

ePiccolo Engineering

0 Kudos
Reply