• 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 : 1266
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: online
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 : 4011
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
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 : 4011
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
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 : 3990
  • 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 : 28936
  • 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 : 1266
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: online
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
sjb741
Super Member
  • Total Posts : 837
  • Reward points : 0
  • Joined: 2010/01/25 08:45:39
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/11/20 09:05:33 (permalink)
0
*Modified/simplified this post in view of uncertainty*
 
XC8 2.20
I might have the same issue as the O.P. - Not yet sure. The example RTCC project is OK. Program Memory View shows an ISR at 0008.
 
As a contrast, I am trying to compile and make work an existing project (USB keypad) from March 2017, and the USB ISR breakpoint seems broken. Needs investigation.
 
The old HEX produces a working 9 button keypad. The new HEX never gets to the 'POWERED' state. I had to modify the old code for the new compiler @2000 --> __at(2000), interrupt --> __interrupt().
 
 
post edited by sjb741 - 2020/11/21 10:21:56
#11
ric
Super Member
  • Total Posts : 28936
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Interrupt vectors missing from compiled code 2020/11/20 13:09:46 (permalink)
+1 (1)
sjb, you're plainly using C99 mode on source code written for C90 mode.
 

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!
#12
sjb741
Super Member
  • Total Posts : 837
  • Reward points : 0
  • Joined: 2010/01/25 08:45:39
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/11/21 09:52:57 (permalink)
0
Yes thanks - I realise that... I read that C99 is the new default for XC8. AFAIK, when you install the XC8 2.2x, then it assumes C99, but does not notice the old code was C90. The old code was based upon Microchip code, AN1546.
 
I did not find how to disable C99 mode from MPLAB X, I hope it's just a check box? Whether I then have to change the __at back to @ or not I am unsure. Ultimately of course I'd rather stay with C99 mode - and have working ISRs too, after all it's only 21 years after the standard was finalised now (!)
 
I set up a simple test ISR project for the 16F1454 - the breakpoint does not break-up and the ISR works.
 
So now I admit I do not know if I have a valid 'issue' - I do not yet understand why the old project has the ISR problem.
post edited by sjb741 - 2020/11/21 10:02:07
#13
NKurzman
A Guy on the Net
  • Total Posts : 19023
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/11/21 11:38:54 (permalink)
0
It is a checkbox in the project settings.
Or you can start with the compiler that the code was written with.
#14
ric
Super Member
  • Total Posts : 28936
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Interrupt vectors missing from compiled code 2020/11/21 15:58:43 (permalink)
-1 (1)
NKurzman
It is a checkbox in the project settings.

https://microchipdeveloper.com/xc8:moving-to-xc8-2-0
 

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!
#15
mpgmike
Super Member
  • Total Posts : 493
  • Reward points : 0
  • Joined: 2014/01/23 17:27:06
  • Location: NJ
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/11/22 11:10:25 (permalink)
+1 (1)
I'm using some old USB code on a PIC16F1455 and found that not only did I have to revert to C90, but also had to go back to XC8 v1.45 and MPLABX v4.xx to get everything to work.  For me it was easier to "cheat", as this was just a 1-off engineering project that will not see production.

I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
#16
sjb741
Super Member
  • Total Posts : 837
  • Reward points : 0
  • Joined: 2010/01/25 08:45:39
  • Location: 0
  • Status: offline
Re: Interrupt vectors missing from compiled code 2020/11/25 02:11:31 (permalink)
0
I made a copy of the problem project, added 2 NOP() for definate breakpoints and the the resulting screenshot is shown.
 
In the MAP file I see
SYSTEM_Initialize@state                     cstackCOMMON 00072
 
But no mention of
SYS_InterruptHigh
 
I'll see if I can whittle the project right down --->

 
I started removing code. After I removed a few major calls from main(), I encountered this
 
"error: (1347) can't find 0x1 words (0x1 withtotal) for psect "cstackCOMMON" in class "COMMON" (largest unused contiguous range 0x0)"
 
If commenting out code gives this error, I am confused!
 
post edited by sjb741 - 2020/11/25 02:21:40

Attached Image(s)

#17
Jump to:
© 2020 APG vNext Commercial Version 4.5