• MPLAB XC8
  • Interrupt vectors missing from compiled code
2020/05/20 13:03:22
Djay
I am compiling using the XC8 V2.1 compiler (C99 mode) in Windows 10 for a PIC18F46J50 chip. I am using the new interrupt declaration standard supported by XC8 V2.x as follows:
 
void __interrupt(high_priority)  SYS_InterruptHigh(void)
{...}
void __interrupt(low_priority)  SYS_InterruptLow(void)
{...}
 
The code compiles and runs only no interrupts are serviced. I am unable to put breakpoints in the interrupt code (they show as "broken breakpoints") so apparently the compiler has "optimized" this code out of existence. I have enabled prioritized interrupts (IPEN=1) and enabled interrupts in my initialization code. Have done this hundreds of times in previous projects, but not using the latest 2.x compiler. Got to be something simple wrong here!
 
My PSECT usage shows there is nothing located at the interrupt vector addresses (0x0008, 0x0018):
 
Psect        | Contents                        | Memory Range | Size
------------|-----------------------------|------------------|--------------
init           | Initialization code           | 0000h - 0003h | 4 bytes
text79      | Program and library code | A326h - A32Bh | 6 bytes
 
Thx!
2020/05/20 13:36:47
mad_c
Hi,
 
The compiler certainly knows not to optimize away interrupt routines. If your ISRs are not appearing in any output whatsoever, then it is most likely that they were excluded from the compilation. Is there any chance that they have been commented out, made conditional, or are in a source file that has not been added to the project?
 
Jeff.
2020/05/20 14:01:54
Djay
Jeff,
That was my first thought, and yes these ISRs are in a separate source file. I cut and pasted them into my main.c project source file and recompiled with same result- my code compiles, loads, and runs, but there are no links to the ISRs down at the vector addresses and attempting to set a breakpoint anywhere in either of the ISRs shows up as a "broken breakpoint". To take that one step further, a search in the .map file created confirms that neither ISR name shows up.
2020/05/20 14:08:37
du00000001
What about messages/warnings during compilation/linking?
2020/05/20 14:31:05
Djay
There are about 18 warnings, mostly related to USB code files that don't meet the more rigorous standards of the C99 language standard. No warnings in the isr.c file where these interrupt handlers are located. This file is included in the project build, and I have tested moving the ISR code into the main.c project file with no change in the result. Could the packs loaded (PIC18F-J_DFP) have anything to do with this? I am at a loss at the moment. I am about ready to manually stuff the vector table as a work-around, but I am not sure at this time if the compiler will allow me to do that.
2020/05/20 15:16:34
du00000001
About time to upload your project (zip, then add a 2nd extension ".txt" to be able to upload).
Or upgrade to the latest compiler version (v2.20 IIRC).
2020/05/20 15:29:45
dan1138
@Djay,
 
The attached project builds correctly with MPLABX v5.35 and XC8 v2.10.
 
Could you try it on your workstation?
 
See if your results are correct or if the results are missing the interrupt handlers as you posted.
2020/05/20 15:31:13
Djay
Some progress... albeit requiring a step backwards! I had already tried installing/compiling with the XC8 V2.20 version of the compiler and I had the same problem as originally described. I then reverted back to V1.45 and voila, it works. It would appear there is a bug introduced in the V2.x version of the compiler. Why I am seeing this and apparently no one else has (to date), is still a mystery. There are some issues with me being able to upload this code, as it technically is the property of my client.
2020/05/20 15:33:40
ric
Try Dan's code.
 
2020/05/21 13:47:23
mad_c
Hi,
 
Aside from trying the other project posted in this thread, look for the preprocessed file (.i extension) associated with the ISR source file. In the IDE, you will find this in the directories below <project>/build. If you cannot see the interrupt code in the preprocessed output, then the preprocessor has removed it, for whatever reason that you can explore. If it is there, what happens if you add an error to the ISR so that it should not build? Is the code generator seeing it at all?
 
Jeff.
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account