Forums

interrupt handling using microblaze with XPS

Started by chriskoh December 19, 2006
Hi,
   I am pretty new to the arena of interrupt handling and would need
some help. I am currently using microblaze v4.00a and with  Xilinx
platform studio 7.1 to develop some UART handling routines. what I am
not sure, is

1) whether the important registers (eg, stack pointers and other
registers) are saved during an interrupt handling, or do I have to
explicitly save them myself.

   I dun think this is handled by the microblaze and am wondering if
the mb-gcc C compiler would be smart enough to do the same.

kindly advice. thanks!
Chris

chriskoh wrote:
> > I am pretty new to the arena of interrupt handling and would need > some help. I am currently using microblaze v4.00a and with Xilinx > platform studio 7.1 to develop some UART handling routines. what I > am not sure, is > > 1) whether the important registers (eg, stack pointers and other > registers) are saved during an interrupt handling, or do I have to > explicitly save them myself. > > I dun think this is handled by the microblaze and am wondering if > the mb-gcc C compiler would be smart enough to do the same.
That depends on the machine you are using. Read its documentation. For example, an X86 saves the return address and the program status (flags, interrupt enables, etc.) automatically. Others may differ. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net>
On 2006-12-19, CBFalconer <cbfalconer@yahoo.com> wrote:
> chriskoh wrote: >> >> I am pretty new to the arena of interrupt handling and would need >> some help. I am currently using microblaze v4.00a and with Xilinx >> platform studio 7.1 to develop some UART handling routines. what I >> am not sure, is >> >> 1) whether the important registers (eg, stack pointers and other >> registers) are saved during an interrupt handling, or do I have to >> explicitly save them myself. >> >> I dun think this is handled by the microblaze and am wondering if >> the mb-gcc C compiler would be smart enough to do the same. > > That depends on the machine you are using. Read its > documentation. For example, an X86 saves the return address and > the program status (flags, interrupt enables, etc.) automatically. > Others may differ.
The 68HC11 for example saves all registers on the stack. Others (e.g. NIOS2) save nothing on the stack and just swap a couple registers. -- Grant Edwards grante Yow! My forehead feels at like a PACKAGE of moist visi.com CRANBERRIES in a remote FRENCH OUTPOST!!
"chriskoh" <chrisdekoh@yahoo.com> wrote in message 
news:1166549588.432486.37750@73g2000cwn.googlegroups.com...
> Hi, > I am pretty new to the arena of interrupt handling and would need > some help. I am currently using microblaze v4.00a and with Xilinx > platform studio 7.1 to develop some UART handling routines. what I am > not sure, is > > 1) whether the important registers (eg, stack pointers and other > registers) are saved during an interrupt handling, or do I have to > explicitly save them myself. > > I dun think this is handled by the microblaze and am wondering if > the mb-gcc C compiler would be smart enough to do the same. > > kindly advice. thanks! > Chris
I have just been looking at the FreeRTOS.org Microblaze demo to see how that configured the interrupts. It seems that the development environment handles all the interrupt prologue and epilogue code for you. From the FreeRTOS.org documentation: "An interrupt service routine that does not cause a context switch has no special requirements and can be written as a normal function." and looking through the code the serial port interrupt is just written as: void vSerialISR( void *pvBaseAddress ) The fact that it takes a parameter means it cannot be called directly in response to an interrupt, but indirectly after some processing. So I would conclude - you have to write your ISR like a standard function without having to worry about the save and restore of any of the registers. Saving of general purpose registers is handled by the tool. Saving of other registers is handled by the hardware itself. Once you have written your ISR you have to somehow tell the tool about it through the GUI. The file xintc_g.c is then automatically generated to contain the interrupt table and references to your ISR functions. Sorry I cannot remember specifics but I hope this is a pointer. Regards, Richard. + http://www.FreeRTOS.org + http://www.SafeRTOS.com for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430 Microblaze, Coldfire, AVR, x86, 8051, PIC24 & dsPIC
Grant Edwards wrote:
> On 2006-12-19, CBFalconer <cbfalconer@yahoo.com> wrote: >> chriskoh wrote: >>> >>> I am pretty new to the arena of interrupt handling and would need >>> some help. I am currently using microblaze v4.00a and with Xilinx >>> platform studio 7.1 to develop some UART handling routines. what I >>> am not sure, is >>> >>> 1) whether the important registers (eg, stack pointers and other >>> registers) are saved during an interrupt handling, or do I have to >>> explicitly save them myself. >>> >>> I dun think this is handled by the microblaze and am wondering if >>> the mb-gcc C compiler would be smart enough to do the same. >> >> That depends on the machine you are using. Read its >> documentation. For example, an X86 saves the return address and >> the program status (flags, interrupt enables, etc.) automatically. >> Others may differ. > > The 68HC11 for example saves all registers on the stack. > Others (e.g. NIOS2) save nothing on the stack and just swap a > couple registers.
Another variation is delay in re-enabling interrupts. This is often intended to allow the system to return to the interrupted code before executing another interrupt. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net>