WE are using mc9s12xeq512 family. Currently our ram size 32kb.
consider a local variable which is in stack I.e non paged ram ( ram fe, Ram FF) multiplied with another global variable in paged ram I.e ram FD. I'm didnt faced any issues and the operation was proper.
when the same local variable in stack (non paged ram) multiplied with variable placed in ram FC (paged ram). Multiplication done by micro controller is not proper.
Header 1 | Header 2 |
---|---|
ram fa | |
RAm fb | |
RAm fc | |
RAm fd | PAgeD ram |
RAm fe | NOn pageD ram |
RAm ff | NOn paged ram |
this is a strange problem. is there any limitations on ram jumping in Freescale micro controller...?
uninitialised global variables is shows as .bss in non paged ram and when the same global variable is placed in non paged ram why .bss doesn't picture.?
Could you provide some code that demonstrates the problem?
There is a very important compiler option -PSegObj/-PSegNonDef/-PSegAll. See in Code Generation tab "Assume object are in same page for".
Default setting is -PSegNonDef or "all objects in same non default segment". Here segment really means PRM PLACEMENT, PRM SEGMENT. Default PRM file has defined PAGED_RAM PLACEMENT, which consists of bunch of 4k RAM SEGMENT's. So -PSegNonDef is not really compatible with multipage PLACEMENT's, unless you are using only up to 4k of paged RAM, which would make linker allocating all paged RAM variables on the same page. If you are over 4k, then you either need to:
1) Use -PSegObj "never for different objects" setting
2) Edit PRM file and define different placements for different RPAGE - pages. Then try placing all variables first in first page. When linker complaing about no space in first page, move some variables to next page and so on.
1st way is maybe simpler, but 2nd makes compiler generating less and more faster code.
Some links that may help:
Re: Paged ram/ far pointers CW S12X
Re: How to copy a 8 byte array from non banked ram to banked ram
Re: RAM Paging in MC9S12XDT512
Re: S12XDT256 and CW4.5: How to include one of the RAM pages in link map
ex:
#pragma DATA_SEG DEFAULT
unsigned int a=10;
unsigned int b;
act()
{
b=a;
}
case 1:
now consider that the freescale compiles and allocates both the variable in ram i.e in banked memory i.e RAM FB. Current stack size is 1k.
operation is proper
case 2:
now consider that the freescale compiles and allocates both the variable in ram i.e in banked memory i.e RAM FB. Current stack size is increased to 2k.
operation is not proper ???............i mean value 'a' is not copied to 'b' . Both variables are located in the same ram page (RAM FB) but in different locations.
1. how increasing the stack size impacts the sytem?
2. is there any rules for handling variables in banked page?
Again, could you provide some code that demonstrates the problem? Your problem description is very fuzzy. I think we won't make any progress solving it, unless you show us some CW project that demonstrates the problem.
#pragma DATA_SEG DEFAULT
unsigned int ECT_freq_l_U32 ;
unsigned int FI ;
void Update_Frequency_module(){
ECT_freq_l_U32= 40/20;
FI= (unsigned long)ECT_freq_l_U32
}
So just consider that the variables ECT_freq_l_U32 placed in one banked ram page FC
Variable FI is placed in another banked ram page FD
The entire function(Update_Frequency_module()) is placed in the is placed in paged flash .
How the ppage register will be handled in this case?... whether this particular code will work?
What memory model are you using? The most of users use banked memory model. In this memory model DATA_SEG DEFAULT makes variables allocated in nonpaged RAM only. It is not possible that ECT_.. is placed on page FC, and FI on page FD. Also PPAGE register has nothing in common with RAM paging on S12X. Like I said, your problem description is extremely fuzzy and not clear.
hmmm..... ur ri8 ... Sorry for putting fuzzy queries.... but i will continue to explain and sorry for not being clear!!!
all the global variables in our software model comes under
#pragma DATA_SEG default. We are using banked memory model. We have loads of global variables which is around 10k. Thereby compiler starts accomodating the variable from non-paged ram ( RAM FE,FF). Once its non paged rams are filled, compiler starts accomodates remaining global variables(#pragma DATA_SEG default) in banked ram pages(RAM FD,RAM FC etc....................).
now ill add up my previous code
#pragma DATA_SEG DEFAULT
unsigned int ECT_freq_l_U32 ;
unsigned int FI ;
void Update_Frequency_module(){
ECT_freq_l_U32= 40/20;
FI= (unsigned long)ECT_freq_l_U32
}
So just consider that the variables ECT_freq_l_U32 placed in one banked ram page 'FC'. Variable 'FI' is placed in another banked ram page 'FD' . Under this case, whether there will any problem in page switching. My operation is not proper under this case!!!
Did you change DEFAULT_RAM placement in PRM file? Originally it should look like this:
DEFAULT_RAM /* all variables, the default RAM location */
INTO RAM;
If it is not touched, then compiler can't place variables in paged RAM! If indeed you changed it, then no wonder you have problems. You can't include paged RAM segments in DEFAULT_RAM placement when using BANKED memory model. Instead you should tell compiler which variables to allocate in paged RAM using DATA_SEG pragmas, like this
#pragma DATA_SEG PAGED_RAM
// put here your paged RAM variables
#pragma DATA_SEG DEFAULT
When declaring global paged variables (extern's in *.h file), they also should be put between DATA_SEG pragmas. For example global paged var1 can be defined in C file
#pragma DATA_SEG PAGED_RAM
char var1;
#pragma DATA_SEG DEFAULT
and declared in *.h file:
#pragma DATA_SEG PAGED_RAM
extern char var1;
#pragma DATA_SEG DEFAULT
linker file is represented as follows,
default ram
into
ram,ram fd,ram fc;
so compiler fills all the global variables in non paged ram. Once non paged ram filled, compiler will start filling paged ram ram fd and ram fc.
so please refer the previous program n problem
linker file is represented as follows,
default ram
into
ram,ram fd,ram fc;
You can't do this. Paged RAM can't be included in default RAM placement.
so compiler fills all the global variables in non paged ram. Once non paged ram filled, compiler will start filling paged ram ram fd and ram fc.
Linker does what you ask it, it puts stack and your variables first to non paged RAM, then to paged RAM segments FD and FC. But unfortunately this is not enough for compiler to generate proper code to access objects in paged memory.
You need to restore PRM file to original and use #pragma DATA_SEG to tell compiler 1) what objects are paged, 2) how compiler should access them, 3) and what placement to allocate object to.
1) To tell what variables, declare and define variables between these pragmas
#pragma DATA_SEG ...
// put your paged variables here
#pragma DATA_SEG DEFAULT
2) to tell how compiler should access them, use either __RPAGE_SEG or __GPAGE_SEG attribute (which I missed in my previous message). Paged RAM is accessed either switching RPAGE register, or using global memory addressing and switching GPAGE register. So
#pragma DATA_SEG __RPAGE_SEG ...
// put your paged variables here
#pragma DATA_SEG DEFAULT
3) to tell what PRM PLACEMENT to use:
#pragma DATA_SEG __RPAGE_SEG PAGED_RAM
// put your paged variables here
#pragma DATA_SEG DEFAULT
1. Is there any provision for clearing ram. Currently we are clearing ram only at the instant of battery off/on . Is it the best practise?...........
Is there any possibility of ram to corrupt, when a system continuously runs for a week