I'm new to both SDCC and embedded programming, and I'm having difficulty getting an ISR to work. The processor I'm targeting is the Phillips/NXP P89V664, and it has an interrupt that occurs on a timer overflow. In the processor datasheet, it lists the interrupts. My question is this: it doesn't list an "interrupt number." The information for the interrupt I'm interested in is:
Flag Vector addr. Int. enable Int. pri Svc. pri.
TF0 000BH ET0 PT0/H 3
(TF0, ET0, and PT0 are all SFRs.)
In SDCC, you specify an "interrupt number" (void myInt() __interrupt 1, for example). But I have no "interrupt number." I've tried 0, 1, and 3, and it doesn't seem to work.
I've looked at the listing, and I can't quite figure out what's going on from that. I have a (working) assembler program, and it just uses a .org to position the interrupt routine at 000BH. I saw a thread on this forum where someone was asking how to arbitrarily position a function in memory, and I suppose I could use one of those suggestions, but it would be cleaner if I could use the ISR syntax that SDCC has.
Interrupts are tricky. I haven't used the NXP P89V664, but assuming it has a standard 8051 core then the SDCC syntax for the TF0 interrupt handler is:
void TF0_isr (void) __interrupt(1)
In general, the interrupt number can be calculated from the interrupt vector by subtracting 3 and dividing by 8.
Note that apart from the many ways of mis-configuring the hardware, SDCC also imposes the requirement that the source file containing main() must include a prototype of the ISR.
Hey, it works like a charm. Thanks for the help. I thought I had tried interrupt 1, but maybe I had something else incorrect.
Log in to post a comment.