• AVR Freaks

AnsweredHot!Interrupt vectors missing from compiled code

Author
Djay
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2013/03/06 10:12:09
  • Location: 0
  • Status: offline
2020/05/20 13:03:22 (permalink)
0

Interrupt vectors missing from compiled code

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!
#1
mad_c
Super Member
  • Total Posts : 1258
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/20 13:36:47 (permalink) ☼ Best Answerby Djay 2020/05/20 13:52:20
+3 (3)
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.
#2
Djay
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2013/03/06 10:12:09
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/20 14:01:54 (permalink)
0
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.
#3
du00000001
Just Some Member
  • Total Posts : 3942
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: Interrupt vectors missing from compiled code 2020/05/20 14:08:37 (permalink)
+1 (1)
What about messages/warnings during compilation/linking?

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#4
Djay
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2013/03/06 10:12:09
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/20 14:31:05 (permalink)
0
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.
#5
du00000001
Just Some Member
  • Total Posts : 3942
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: Interrupt vectors missing from compiled code 2020/05/20 15:16:34 (permalink)
+1 (1)
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).

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#6
dan1138
Super Member
  • Total Posts : 3827
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/20 15:29:45 (permalink)
+2 (2)
@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.
#7
Djay
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2013/03/06 10:12:09
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/20 15:31:13 (permalink)
+2 (2)
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.
#8
ric
Super Member
  • Total Posts : 28324
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Interrupt vectors missing from compiled code 2020/05/20 15:33:40 (permalink)
+2 (2)
Try Dan's code.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#9
mad_c
Super Member
  • Total Posts : 1258
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/05/21 13:47:23 (permalink)
+5 (5)
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.
#10
Jump to:
© 2020 APG vNext Commercial Version 4.5