Locating ROM_VAR section in paged memory of S12XEP100 target

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

Locating ROM_VAR section in paged memory of S12XEP100 target

Jump to solution
1,360 Views
sep2kor
Contributor III

Hello,

 

I am using S12XEP100 target.

 

I have located all the constants i.e.. ROM_VAR section in my project to paged memory. But when I do this, the address of the constant pointers is not getting loaded properly into the CPU registers.

 

E.g.:

I have located a constant structure in my application software to paged memory. So, the address of this constant structure is 3 bytes long. But when the address of this constant structure is passed as an argument to a function, only the first 2 bytes of the constant structure's address is passed. The page number where the constant structure is located is not passed to the function. And hence my SW does not work properly.

 

I tried to make the address passed as "__far" address. But this did not solve my problem.

 

Can anyone help me?

 

Note:

The unpaged memory in my project is completely reserved for BootLoader. All my Application SW is linked to paged memory.

 

Thank You,

 

Sandeep

Labels (1)
0 Kudos
1 Solution
683 Views
sep2kor
Contributor III

I am currently changing my memory layout.

 

I want to know, whether the address range between 0x8000 - 0xBFFF (page - 0xFE) in the local memory map, can be used as unpaged memory?

 

 Sandeep

View solution in original post

0 Kudos
10 Replies
683 Views
kef
Specialist I
  • The unpaged memory in my project is completely reserved for BootLoader. All my Application SW is linked to paged memory.

 

This is not right. You neeed unpaged memory for interrupt service routines. You may trim size of ISR's in unpaged code to just two instructions call (calling rest of ISR in paged memory) and rti, but that's still some bytes in nonpaged memory.

 

To improve application performance it helps if you leave constants in unpaged memory.

 

32kB bootloader is something very big

0 Kudos
683 Views
sep2kor
Contributor III

Yes Kef.

You are right!

 

We are now locating the ASW ISR's and the constants in unpaged flash. Moving the bootloader to paged memory.

 

Yes....the bootloader is huge in our project :smileysad:

 

Thanks a lot Kef!

0 Kudos
683 Views
CompilerGuru
NXP Employee
NXP Employee

Check that the pragma allocating the section also has the proper __GPAGE_SEG qualifier as the compiler has to know how to access the constants. Then make sure the #pragma CONST_SEG  __GPAGE_SEG XXX_SEC is also present in front of the declarations (if any), not just in front of the definition. In header files, restore the previous section with a surrounding #pragma push/#pragma pop.

The function taking the address needs a __far pointer, only using a __near pointer wont take all the 3 address bytes.

Finally I would not use the default ROM_VAR as name for a custom allocated section. Predefined section names have also predefined meaning, I'm not sure if ROM_VAR in particular is specially handled anywhere, but it could be.

 

If this does not help, please show how you declare and use the constants, how your prm looks like, what you see and what you expect to see.

As always, are there any compiler warnings?

 

Daniel

0 Kudos
683 Views
sep2kor
Contributor III

Thanks Daniel!

 

I changed the pointer as __far in all places in the c-file and header files and it is working now.

 

In prm, i did the changes highlighted below in red.

 

SEGMENTS

...

...

...

PAGED_FLASH_E5 = READ_ONLY DATA_FAR IBCC_FAR 0xE58000 TO 0xE5BFFF;

...

...

END

 

But, what is the significance of IBCC_FAR and DATA_FAR?

 

I just copied these 2 from the demo prm file given by CodeWarrior.

 

Sandeep

 

 

 

0 Kudos
683 Views
CompilerGuru
NXP Employee
NXP Employee

If you don't know what they do and if your app works without them, I would not add them :smileyhappy:.

 

I actually don't know without reading the linker manual. My guess would be that those are for the automatic distribution of variables to pages, something I did not use.

 

Daniel

0 Kudos
683 Views
sep2kor
Contributor III

I have one more question w.r.t my first post.

 

Say...all the functions, which access the constant structure are located in one paged memory, should the constant structure be still addressed as __far ?

 

Sandeep

 

 

0 Kudos
683 Views
CompilerGuru
NXP Employee
NXP Employee

You need __far access if the code dereferencing the pointer is allocated on another page. If the code is unpaged or allocated on the same page, then just making sure PPAGE is set and accessing the constants with __near pointer should work too. Still a bit dangerous because nothing will warn you when code running on another page tries to access the constants.

 

Daniel

0 Kudos
681 Views
sep2kor
Contributor III

I will try linking as many functions and the contants used in thse functions into one page.

 

Regarding the linker attribues - IBCC_FAR abd DATA_FAR, i could not find their explainations in the compiler-linker manual.

 

Thanks Daniel!

0 Kudos
681 Views
kef
Specialist I

See

 

<CW root folder>\Help\PDF\Compiler_HC12.pdf"

 

To try it create new project using project wizard and check some MemoryBanker options and see if it is useful for you. I wonder why this option is available only for S12X parts.

 

0 Kudos
684 Views
sep2kor
Contributor III

I am currently changing my memory layout.

 

I want to know, whether the address range between 0x8000 - 0xBFFF (page - 0xFE) in the local memory map, can be used as unpaged memory?

 

 Sandeep

0 Kudos