- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
![](/skins/images/D3C0B914909A6564BBB97F4AD1ED1973/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page