MC9S12XEQ512 banked data question

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

MC9S12XEQ512 banked data question

1,263 Views
JohnBarber
Contributor II

I have a large number of files originally coded for another processor not using banked RAM. When I now compile the files for the S12X, some of the data is placed in banked RAM.

 

In several places, where I want to access the banked data, the compiler does not produce the correct instructions. Pointers to the data points to the CPU local map instead of the global map.

 

Is there a way to instruct the compiler to always use global addressing?

 

Or do I have to walk through my code and insert @gpage @far at every variable declaration?

 

I am using the Cosmic S12 compiler 4.7.12

 

/John

Labels (1)
0 Kudos
3 Replies

410 Views
Pedro_
Contributor III

Hi John,

 

I don't have experience with the part you are working with and haven't had the need of using paged RAM so far, but I might be able to give you some ideas.

  

I think Parser option -m0x30 will result in all data being treated as paged. I wouldn't recomend it though. You'd be spending time treating data in the @near area as if it was in @far areas.

 

BEWARE! You must use @svpage modifier with interrupts that will handle paged data (or any function called from tne interrupt context). Otherwise, the registers won't be stacked and you'll go crazy trying to figure out how your data gets corrupted!

 

I wouldn't use @gpage @far, that's used for accessing the whole memory map. I am not even sure if it will work with data.

 

It might be worth just defining fdata segments in the paged ram and either linking the objects right there or using pragma around the variable declaration. The modifier to use is plain @far.

 

For example

+seg .fdata -b0x0FA000 -o0x1000 -m0x1000 .nPagedData

 data.o   #either link the object here (object contains only data instances, no code!)

 

or use pragma

 

#pragma section @far {PagedData}

unsigned int myData;

#pragma section @far {}

 

If you use pragma, don't forget about the differnces between the square and curly brackets (uninitialized and initialized data).

 

I hope the info helps

 

 

 

0 Kudos

410 Views
JohnBarber
Contributor II

Hi,

thanks for your help.

But my problem is not to place data in paged ram. The problem is when I try to access the data.

If I assign the address of paged data to a pointer, it will get the local address of the object.

/John

0 Kudos

410 Views
Pedro_
Contributor III

 

In that case, I believe you need to add the @far modifier to the pointers used to access paged data.

 

Using the parser option might also do the trick, but you'll have to experiment.

 

Post when you find the solution, it'd be interesting to know.

0 Kudos