|
|
View previous topic :: View next topic |
Author |
Message |
cdemetri
Joined: 15 Jun 2011 Posts: 2
|
#Locate auto=address usage. relocate scratch variables |
Posted: Wed Jun 15, 2011 5:42 pm |
|
|
Compiler Version 4.119
Target 18F6227
I have reviewed the past posts regarding relocating the automatically generated scratch variables.
Here is a snippet from my symbol file showing what scratch variables I am referring too.
The reason I need to relocate is I use high and low priority interrupts and I am finding situations where a high and low priority function share ram space which results in the low priority variable being corrupted.
<snip symbol>
E13 FlushDUARTB_RxBuffer.crit_sect
E13-E14 DU_INTB_isr.rtsched_tmr
E13-E14 DU_INTA_isr.rtsched_tmr
E13 FlushDUARTA_RxBuffer.crit_sect <LOW PRIORITY
E13 MngRTSCHED_TaskScheduler.@SCRATCH1
E13 IntrptTIMER1_Periodic10ms.@SCRATCH1 <HIGH PRIORITY
E13 IntrptUART1_Rx.@SCRATCH1
E13 IntrptUART2_Rx.@SCRATCH1
E13 IntrptUART1_Tx.@SCRATCH1
E13 IntrptUART2_Tx.@SCRATCH1
E13 timer3interupt.@SCRATCH1
E13 ManageDUB.@SCRATCH1
<end>
From previous posts I have found numerous ways to relocate user variables by declaring them as static or using the locate keyword. However I can not find a successful way to relocate scratch variables.
One suggestion was made to use #locate auto=address in the desired function. The documentation also mentioned this under the #LOCATE key word. However, when I try to use the line #locate auto=address I get quite a few errors. Error 28 Expecting an identifier.
It doesnt matter what I do, even an empty function generates errors.
*** Error 28 "d:\timers.c" Line 165(1,6): Expecting an identifier
void function ( void )
{
#locate auto=0x100
}
I do not have any ORG's in my code, and do not use the word auto anywhere in my code, perhaps this is the problem.
any ideas?
++++
1) I have confirmed that the ISR is not saving and restoring these variables. I am not referring to the ISR SCRATCH area at the bottom of memory. I am referring to function scratch registers.
2) I have confirmed that the low priority interrupt function variable is getting corrupted. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 16, 2011 2:13 pm |
|
|
Quote: | void function ( void )
{
#locate auto=0x100
} |
It gives the same error in vs. 4.121.
I have emailed CCS about it. |
|
|
cdemetri
Joined: 15 Jun 2011 Posts: 2
|
|
Posted: Thu Jun 16, 2011 3:04 pm |
|
|
Thanks for emailing CCS.
I have also emailed them about it.
Hopefully we can get an answer to this. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Jun 17, 2011 2:51 am |
|
|
If you want to get working, while waiting for CCS, the answer is to #ORG your high priority interrupt code.
If you work out the total size of your high priority code, and add:
#ORG 0x100,0x1000, default
in front of the first high priority routine, with the first number chosen to put the code somewhere down near the interrupt dispatcher, and the second chosen to leave enough room for all the code, then have all the high priority routines, and follow these with:
#ORG default
and the rest of your code.
Separate 'scratch' storage will be generated for all the high priority routines.
Downside is it means _you_ have to allocate the storage for the routines (the #locate option should leave this as automatic, only changing the scratch storage part), but it should solve the current problem. As a very crude example (using FP multiply as the routine wanting a separate scratch area)
Code: |
#include <testISR.h>
#ORG 0x100,0x800 default
void testfn(void) {
int8 dummy;
float test=1E7;
for (dummy=1;dummy<10;dummy++) {
test*=dummy;
}
}
#ORG default
void main(){
float another=23.4;
another*=2.04;
do {
} while(TRUE);
}
|
Gives the .sym showing:
Code: |
009-00C @MULFF.P1
00D-010 @MULFF.P1
011 @MULFF.@SCRATCH1
012 @MULFF.@SCRATCH2
013 @MULFF.@SCRATCH3
014 testfn.dummy
015-018 testfn.test
019-01C @[email protected]
019-01A @[email protected]
01D-020 @[email protected]
021 @8@MULFF.@SCRATCH1
022 @8@MULFF.@SCRATCH2
023 @8@MULFF.@SCRATCH3
|
While doing this without the #ORG's gives just one scratch area for the multiply.
This should not be necessary. The #locate ought to work, but also, the compiler ought to be realising that HP interrupts need a local scratch area automatically....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|