Use large arrays in MC9S08QE64

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Use large arrays in MC9S08QE64

跳至解决方案
2,011 次查看
davebv
Contributor III

Hi,

 

Hi have a project which uses large arrays of constant data (14 arrays of 2048 bytes each and a bigger one, so the total object size of the arrays is 36082 bytes)

And I am a little bit lost on how to compile the application and make the PRM files.

By using the default settings generated by codewarrior I get the expected error that the data does not fit in ROM.

 

Link Error : L1102: Out of allocation space in segment ROM at address 0x7130

 

I started with SMALL memory model.
Then, I added  ROM1   =  READ_ONLY    0xC000 TO 0xFFAD; to SEGMENTS and  ROM1 to DEFAULT_ROM, COPY INTO ROM, ROM1;
With the compiler option -OnB=b, as stated in the prm file.
Still does not provide enough space.
So I added a new segment called ROM3  =  READ_ONLY    0x8000 TO 0xBFAD; and to default_rom, but despite it gives me enough space, when running it does not work.
How do I solve the problem os use large arrays?
Thanks for your help
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
914 次查看
davebv
Contributor III

Thank you all very much for your comments, finally I managed to solved the issue. The key point was to write the memory address to point to page_2 instead of page_0.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
914 次查看
CrasyCat
Specialist III

Hello

 

If you want to place your constant tables in paged Flash, you can define the constants in a linear constant segment (#pragma CONST_SEG  __LINEAR_SEG PAGED_ROM) and access the data using linear pointers.

 

Project {Install}\(CodeWarrior_Examples)\HCS08\Evaluation Board Examples\DEMOQE128\DEMOQE128_LAP_Dictionary on V6.x shows how this can be done.

 

CrasyCat

0 项奖励
回复
914 次查看
Navidad
Contributor III

 

Some things that come to my mind as solutions to your problem (I am assuming the default PRM file generated by the project wizard in CW for HC08 6.3):
  1.  Allocate some of your code to pages 0 or 2. To do that, add a #pragma CODE_SEG:
    #pragma push#pragma CODE_SEG __FAR_SEG PAGED_ROM/* code to allocate to page 0/page2 */#pragma pop

     

  2. Use the page 2 directly (just like you attempted to do). Something like this should work (well, it pretty much depends on how much code you have). But bear in mind that this kind of approach more or less means that you will not (easily) use page 0 for placing code.
  3. Place some of your data in either page 0. I would not recommend that since this means linear addressing. This is both inefficient and  not fully supported by the compiler (this means that you need to use some predefined macros or assembly code).

 

0 项奖励
回复
915 次查看
davebv
Contributor III

Thank you all very much for your comments, finally I managed to solved the issue. The key point was to write the memory address to point to page_2 instead of page_0.

0 项奖励
回复
914 次查看
Lundin
Senior Contributor IV

If you allocated it as one single, massive array, it will not fit inside the flash pages. It isn't possible to allocate variables or code across several flash pages.

 

You might have to divide the array into several:

 

#define ARRAY1_SIZE ....
#define ARRAY2_SIZE ....
#define ARRAY3_SIZE ...

#define ARRAY_SIZE (ARRAY1_SIZE + ARRAY2_SIZE + ARRAY3_SIZE)



#pragma CONST_SEG SEG_ARRAY1
const uint8 array1[ARRAY1_SIZE] = ...;

#pragma CONST_SEG SEG_ARRAY2
const uint8 array2[ARRAY2_SIZE] = ...;

#pragma CONST_SEG SEG_ARRAY3
const uint8 array3[ARRAY3_SIZE] = ...;

#pragma INLINE
uint8 array (uint16 index)
{
  uint8 result;
  
  if(index < ARRAY1_SIZE)
  {
  result = array1 [index];
  }
  else if(index < (ARRAY1_SIZE + ARRAY2_SIZE) )
  {
  result = array2 [index - ARRAY1_SIZE];
  }
  else
  {
  result = array3 [index - ARRAY1_SIZE - ARRAY2_SIZE];
  }

  return result;
}

 

 

Then in the .prm file:

 

PLACEMENT

 

SEG_ARRAY1 INTO ROM1; // or whatever segment names you are using

SEG_ARRAY2 INTO ROM2;

SEG_ARRAY3 INTO ROM3;

 

END

 

 

0 项奖励
回复