AnsweredHot!XC8 offset compilation

Author
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
2018/03/12 09:04:12 (permalink)
0

XC8 offset compilation

Hello
 
I have a lot of problem with offset code option in XC8 for more than 1 month. The initial objective is to offset my project in order to have a bootloader project at 0x0 address. I have tested many optimization set of option (Pro, free, space ...) without any success. In order to have some help, I have done two  very basics projects:
- a jump project which only contains jump instructions in main and interrupt routine
- A PAU_TETRA project which only contains:
  • a 5ms periodic interrupt, where a pointer is writing in a stack
  • a main function where the stack are used
The projet PAU_TETRA  is working fine without offset but fails with offset code option. (I have two configurations in MPLABX of PAU_TETRA project, a standalone configuration and a combined configuration). In order to be more precise, in debug mode, I can see that the pointer pe_pile_evt and pl_pile_evt are not at the right address. I don't understand why. On the other hand, I have the feeling that I have a lot of troubles with global variables and pointer when I am offseting my code.
Is there any recommandations in order to use offset command in XC8 ?
In attachment, you can see Jump_preject and PAU_TETRA project . I don't understand what is wrong. I will be very grateful if anyone could help me...
 
Many thanks
 
BR
 
Olivier 
 
#1
mbrowning
Just a Member
  • Total Posts : 1154
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: XC8 offset compilation 2018/03/12 12:27:10 (permalink) ☼ Best Answerby Olivier_Gaborit 2018/04/17 00:49:55
+1 (1)
I suspect the "jump_project" interrupt is saving a lot of context before the "asm goto". Since you have two C projects, the ram overlaps, so bad things happen.
 
You might try generating a bootloader using MCC and see how it handles the interrupts.
 
Or make "jump_project" a simple assembly program rather than C

Oh well - there's always next year
#2
NKurzman
A Guy on the Net
  • Total Posts : 16665
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: XC8 offset compilation 2018/03/12 12:56:11 (permalink)
+1 (1)
Which PIC are you using? XC8 covers a lot of Ground.
 
for a PIC16F1xxx:
 
//******************************************************************************
// Function: isr()
//
// Description: Interrupt Service Stub
// Jump to the Main Applications ISR Vector
// Use this asm goto to avoid the function call overhead.
//
// Parameter(s): None
//
// Return: None
//
//******************************************************************************
#asm
psect intentry, delta=2
PAGESEL(NEW_INTERRUPT_VECTOR);
GOTO (NEW_INTERRUPT_VECTOR);
#endasm
#3
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
Re: XC8 offset compilation 2018/03/13 01:58:45 (permalink)
0
Hello 
 
Many thanks NKurzman and mbrowning for your quick reply.
I'm using PIC18F67J94 device (sorry, I have forgotten to precise in my first post). Unfortunately, MCC is not avaiable with this device.
I have extracted the program memory of jump_project. I join it if it helps. NKurzman; you are suggesting to do program section with PSECT directive ? Could you explain me more, I'm not familiar with PSECT program section.
 
BR
 
post edited by Olivier_Gaborit - 2018/03/13 02:01:09
#4
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
Re: XC8 offset compilation 2018/03/29 00:01:21 (permalink)
0
Hello Everybody
 
Mbrowning were right. In jum project, before to the goto, the Jump_project is saving the context in ram (in my case between address 0x11 and 0x27)
If the other project (PAU_TETRA) have variables at theses address, the Jump project is erasing them. And I have unexpected behavior. 
A workaround is to declare an unused tab (ex unsigned char unused_tab[64] @ 0) in order to keep these address fix.
Now it works. I have a question:
How I can keep free a ram space in my PAU_TETRA project, I have tried the RAM range option in linker option witjout any success. Have you any suggestions ? 
 
Many thanks
 
 
#5
Phil_idee
Starting Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2017/03/27 06:47:41
  • Location: Paris
  • Status: offline
Re: XC8 offset compilation 2018/04/03 09:19:25 (permalink) ☄ Helpfulby Olivier_Gaborit 2018/04/17 00:49:46
+1 (1)
Hi all,
I've got the same trouble using MCC bootloader with a PIC18F87K22 (xc8 1.45, offset 0x800, two pritority interrupts).
I noticed that bootloader save its context from 0x02 to 0x13 that is used by my application variables as well.
I first tried to use "defaut,-0-14" as RAM ranges in linker Memory model. As it looked fine then I downloaded application using bootloader. But application failed.

So I thought than bootloader should not save context as application do it, so I tried :
asm ("PSECT intcode\n goto 0x808 ");
asm ("PSECT intcodelo\n goto 0x818 ");

Compilation was fine for bootloader alone as main project, I got :
0x008 GOTO 0x808
0x018 GOTO 0x818

Compilation was also fine for my application as main project with Conf:combined and with Conf:offset.
Combined application looks well working. I need to check downloading now.

I heared xc8 compiler could turn on or off context saving with Pro mode but not with Free Mode.
Is someone can confirm?
post edited by Phil_idee - 2018/04/04 09:30:24
#6
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
Re: XC8 offset compilation 2018/04/09 07:44:06 (permalink)
0
Hi Phil_idee
,-
I have tried to test your line  in order to  prevent the boot from saving context.
void interrupt high_isr(void)
{
     asm ("PSECT intcode\n goto 0x1008 ");
}
/* Low-priority interrupt routine */
void low_priority interrupt low_isr(void)
{
  asm ("PSECT intcodelo\n goto 0x1018 ");
}
 
In program memory I always have the boot which save the context and no the goto instructions at 0x8 and 0x18.
What is wrong?
In my opinion , the only good way is to prevent the bootloader to save the context
 
BR
 
#7
Phil_idee
Starting Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2017/03/27 06:47:41
  • Location: Paris
  • Status: offline
Re: XC8 offset compilation 2018/04/10 05:16:55 (permalink) ☄ Helpfulby Olivier_Gaborit 2018/04/17 00:50:25
+1 (1)
Hi Olivier,
Just try:
asm ("PSECT intcode\n goto 0x1008 ");
asm ("PSECT intcodelo\n goto 0x1018 ");
No need function declarations, compiler recognize high and low interrupts.
Context saving is done by these declarations.
BR
 
#8
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
Re: XC8 offset compilation 2018/04/12 08:18:30 (permalink)
0
Hi Phil_idee
 
Ok I tested it with success. I will now try to test the program with the boot.
Many thanks
 
BR
#9
Olivier_Gaborit
New Users
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/02/05 07:44:32
  • Location: France
  • Status: offline
Re: XC8 offset compilation 2018/04/17 00:46:53 (permalink)
0
Hi Phil_idee
 
The program is ok with boot. There is no context saving with these commands.
 
Many thanks
#10
Jump to:
© 2018 APG vNext Commercial Version 4.5