View previous topic :: View next topic |
Author |
Message |
Ramey
Joined: 11 Sep 2007 Posts: 18
|
bootloader interrupt dispatch |
Posted: Thu Dec 13, 2007 6:03 pm |
|
|
I want to do something that would seem very simple to me but I can't get the compiler to do it!!!
If the app is running I want interrupts forward to the interrupt vector of the app. If the boot loader is running, I want the bootloader to interrupt handler to handle it. Seems simple enough doesn't it?
Here is the code i want to use to do the job. The compiler doesn't like this as I've used #int_usb in the bootloader code. But for the life I me I can't figure out how to work around this.
Any help would be appreciated.
Robert Ramey
#build{reset=0, interrupts=0x28}
static BOOLEAN in_app = FALSE;
#int_global
void isr_global(){
if(in_app)
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
else
jump_to_isr(0x28);
} |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Fri Dec 14, 2007 8:06 am |
|
|
My requirement was different, but this worked for me:
Code: |
#define HIBEGIN 0x0020 // Hi-Priority Interrupt code starts here;
#define HIFINAL (HIBEGIN + 0x007F)
#define LOBEGIN (HIFINAL + 1) // Lo-Priority Interrupt code starts here;
#define LOFINAL (LOBEGIN + 0x00FF)
#define HIVECTOR (LOFINAL + 1)
#define LOVECTOR (HIVECTOR + 0x0010)
#pragma build (interrupt=HIVECTOR)
#pragma org 0x0008,0x000F // Vector to Hi-Priority Interrupt:
static void HiInt (void)
{
goto_address (HIBEGIN);
}
#pragma org 0x0018,0x001F // Vector to Lo-Priority Interrupt:
static void LoInt (void)
{
// do whatever you want :)
goto_address (LOBEGIN);
}
#pragma org HIBEGIN,HIFINAL // This is the Hi-Priority ISR:
void HiPriorityISR (void)
{
#asm
RETFIE 1
#endasm
}
#pragma org LOBEGIN,LOFINAL // This is the Lo-Priority ISR:
static void LoPriorityISR (void)
{
// do whatever you want :)
#asm
RETFIE 1
#endasm
}
|
Might work for you also. In the HiInt and LoInt, you'll need a test to know where to vector to.
Ken |
|
|
Ramey
Joined: 11 Sep 2007 Posts: 18
|
close but no cigar? |
Posted: Fri Dec 14, 2007 12:58 pm |
|
|
This would seem to be almost what I want. Here I forward to the default global_int located at 0xa0. The 0x009f was determined by inspection of the global_int automatically generated. Any other won't work. This small test should not alter the program in anyway. However, it causes the program to fail. I'm sure that if I can't get this to work I'll be home free.
Any help appreciated.
Robert Ramey
Code: |
#build(reset=0, interrupt=0xA0)
#org 0x0008,0x009f
void isr_global(){
jump_to_isr(0x00A0);
}
#org default
|
|
|
|
|