How to use huge ram on S12XEQ512

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use huge ram on S12XEQ512

Jump to solution
1,178 Views
j_y_
Contributor I

I want to use byte array of 25Kbyte. I know that XEQ512 have 32KByte RAM.

But no matter what, I can not make byte array of about 4KB and over.

I think probably because it would be the prm file setting.

I confuse that how to change which file to get a sufficient amount of RAM.

 

Anyone help me please.

 

CW for HC12 4.6 HCS12X EP100 Service Pack

CW for HCS12(X) Microcontroller v4.6 build 6345

Labels (1)
Tags (1)
0 Kudos
1 Solution
800 Views
kef
Specialist I

#pragma DATA_SEG __GPAGE_SEG PAGED_RAM

 

I suggested to define new placement PAGED_G_RAM. PAGED_RAM in original PRM file consists of a set of 4k RPAGE pages. You need to define one contiguous 'G segment and use it instead.

 

See attached PRM file. It is project wizard created PRM for XEQ512, modified for your needs. 6*4k pages are commented out. Remaining 424 bytes are cut from nonbanked RAM. You only need to replace PAGED_RAM in your code with G_RAM_25k.

I just tried this PRM with your code No problems, it works and verify doesn't break until last i is tested.

 

 

View solution in original post

0 Kudos
6 Replies
800 Views
kef
Specialist I

You need to edit PRM file, disable some RAM segments, create one big contiguous global RAM segment that can hold your big array. Check following thread, also use forums serach

 

https://community.freescale.com/message/110408#110408

800 Views
j_y_
Contributor I

I refered that linked page. and it has been a big help to solve the problem.

 

by the way, i got an other problem. it is a memory corruption.

 

#pragma DATA_SEG __GPAGE_SEG PAGED_RAM
unsigned char large_buff_25k[25000]={0,};
#pragma DATA_SEG DEFAULT

 

....

 

/* memory writing */

unsigned int i=0;

for(i=0; i<25000; i++) large_buff_25k[i] = (i&0xff);

 

/* verification */

for(i=0; i<25000; i++) {

  if((i%0x100) != large_buff_25k[i]) break; // <------ problem occur here

}

 

point of memory corruption is roughly close to 4K bytes.

0 Kudos
801 Views
kef
Specialist I

#pragma DATA_SEG __GPAGE_SEG PAGED_RAM

 

I suggested to define new placement PAGED_G_RAM. PAGED_RAM in original PRM file consists of a set of 4k RPAGE pages. You need to define one contiguous 'G segment and use it instead.

 

See attached PRM file. It is project wizard created PRM for XEQ512, modified for your needs. 6*4k pages are commented out. Remaining 424 bytes are cut from nonbanked RAM. You only need to replace PAGED_RAM in your code with G_RAM_25k.

I just tried this PRM with your code No problems, it works and verify doesn't break until last i is tested.

 

 

0 Kudos
800 Views
j_y_
Contributor I

Thanks for reply and concern.

 

i used prm file you suggest. but that file occur below link error.

 

Error : L1004: Segment start Address expected

 

So, I removed the "DATA_NEAR" and "DATA_FAR" word.

And CW occur another link error.

 

Link Error : L1102: Out of allocation space in segment RAM_G_25k at address 0xF8000

 

i can ask your IDE version if you don't mind.

0 Kudos
800 Views
kef
Specialist I

Probably CW4.6 doesn't like global addresses in PRM file or something. You may try CW5.1 with special edition licence. 

0 Kudos
800 Views
j_y_
Contributor I

i appriate you at all. thanks for advice.

 

i was install CW 5.1 as your advice. but, it was still.

 

so, i dig and dig and dig. as infinite loop.

 

then i found a cause of memory corruption.

 

it is cross-file-using(???) like below code.

 

i was define variables at main.c. and it refered by another file.

 

-- main.c --#define LARGE_BUFF_LEN 25000#pragma DATA_SEG __GPAGE_SEG GRAM_25Kunsigned char large_buff[LARGE_BUFF_LEN];#pragma DATA_SEG DEFAULT-- other.c --#define LARGE_BUFF_LEN 25000      // never mind this :smileyhappy:#pragma DATA_SEG __GPAGE_SEG GRAM_25Kextern unsigned char large_buff[LARGE_BUFF_LEN];#pragma DATA_SEG DEFAULT

 

it was a problem.

 

so, i fix as below code.

 

-- main.c --CopyToLargeBuff(..., ...);-- other.c --#define LARGE_BUFF_LEN 25000#pragma DATA_SEG __GPAGE_SEG GRAM_25Kunsigned char large_buff[LARGE_BUFF_LEN];#pragma DATA_SEG DEFAULTunsigned int CopyToLargeBuff(unsigned char* buf, unsigned int size){  unsigned int cnt=0;  static unsigned int insertion_pos = 0;    if(size == 0) return 0;    do {    insertion_pos %= LARGE_BUFF_LEN;    large_buff[insertion_pos] = buf[cnt];    cnt++;    insertion_pos++;  } while(size != cnt);    return cnt;}

 

i don't know why. but i did fix it. and i can go home.

 

thank you again, kef. have a good day.

0 Kudos