PIC Interrupts - C18 compatibility mode
- From: Steve <steve@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 22:58:15 GMT
I'd appreciate some advice on PIC interrupts under M'chip C18. Just
working on converting some PIC 18F252 C code for use with Microchip
C18, which is new to me, C18 is a good deal more complex than the C
compiler I've used to date, which hid the detailed vectoring -
interrupt setup is a bit trickier... I want to leave the device in
basic 16X compatibility mode as used before, don't need priorities,
only one ISR involved. I understand that I have to get the priority
right as far as the compiler is concerned so that either hardware or
s/w stacks are used for the context save. I'm not sure I've got this
right for compatibility mode as in this case the vector for all
interrupts is 0x08, the high priority vector in 18F priority mode.
I *think* that the only way the compiler decides how to context save
during the ISR is the line #pragma interruptlow (or interrupt) just
before the ISR function itself, hope this is correct?
Anyway, can someone kindly advise if the code below will work to set
up one ISR with C18.
Steve
Code:
/* Interrupt vector setup */
#pragma code low_vector=0x08 //All interrupts at this address
void interrupt_low(void)
{
_asm
goto Interrupt_main
_endasm
}
#pragma code //Returns to previous code section
//and later.....
#pragma interruptlow Interrupt_main
void Interrupt_main(void)
{
if (PIR1 & 0x01) /* Timer 1 interrupt */
.
.
}
.
- Follow-Ups:
- Re: PIC Interrupts - C18 compatibility mode
- From: Fritz Schlunder
- Re: PIC Interrupts - C18 compatibility mode
- Prev by Date: Re: What happens when you over current an inductor?
- Next by Date: Re: Peak detector
- Previous by thread: Change Microchip's PICREF-4 design for 220V
- Next by thread: Re: PIC Interrupts - C18 compatibility mode
- Index(es):
Relevant Pages
|