using Paged RAM

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

using Paged RAM

9,083 Views
opener
Contributor I
Hi,
 
I want to use the paged RAM area in MC9S12XDP512 controller. Can you please help me defining the sections for using this Paged section of RAM and how those functions to be defined(ie., whether it should be defined as FAR function).
 
Thanking you in advance,
 
 
Labels (1)
0 Kudos
Reply
16 Replies

1,481 Views
DanielM
Contributor III
You use modifiers with the data segment definition:

#pragma DATA_SEG: Data Segment Definition

#pragma DATA_SEG (Modif Name | DEFAULT).

Modif:
__SHORT_SEG (compatibility alias: SHORT)
__DIRECT_SEG (compatibility alias: DIRECT)
__NEAR_SEG (compatibility alias: NEAR)
__CODE_SEG (compatibility alias: CODE)
__FAR_SEG (compatibility alias: FAR)
__DPAGE_SEG (compatibility alias: DPAGE)
__EPAGE_SEG (compatibility alias: EPAGE)
__PPAGE_SEG (compatibility alias: PPAGE)
__RPAGE_SEG (compatibility alias: RPAGE)
__GPAGE_SEG (compatibility alias: GPAGE)

The compiler then takes care of everything on its own.

Daniel
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III

Hello

Find attached a technical note describing the different ways of defining paged variables on a HCS12X CPU. It also show the generated code in each case.

Note that this Technical note is part of the standard CodeWarrior for HCS12 V4.5 installation. You can find it in {Install}\Help\Pdf.

CrasyCat

 

TN248.pdf

Message Edited by t.dowe on 2009-10-21 12:28 AM
0 Kudos
Reply

1,481 Views
opener
Contributor I

hi,

i wanted to use the RAM area between 0x00_1000 to 0x0F_FFFF.  So, can you explain me, how i can use that area. For that how do i need to define that memory location in .prm file.  And also explain, how i can define those segments in data segment definiton., like #pragma DATA_SEG  ..........

0 Kudos
Reply

1,481 Views
DanielM
Contributor III
Hi,

in your source file you do:

#pragma DATA_SEG __RPAGE_SEG MY_DATA

..variable definitions go here..

#pragma DATA_SEG DEFAULT

in your header file you do:

#pragma DATA_SEG __RPAGE_SEG MY_DATA

extern ..variable declaration..
...

#pragma DATA_SEG

and in your linker file you have to do:

SEGMENTS
RAM_PAGED = READ_WRITE 0x001000'G TO 0x0FDFFF'G;
END

PLACEMENT
MY_DATA INTO RAM_PAGED;
END

or something of this sort anyway...

Daniel
0 Kudos
Reply

1,481 Views
opener
Contributor I

Hi Daniel,

i am defining the data segment similar way as your instruction, even then there is a warning message like the following one,  when i am trying to access the paged RAM in FB page.

WARNING L1128: Cutting value _Range beg data member from 0xFB1000 to 0x1000.

can you explain me what this states and how it related to my issue.

 

0 Kudos
Reply

1,481 Views
DanielM
Contributor III
Hi,

please have a look at AN3219. It uses paging for variable LCD_data and it all works fine in there.

Daniel
0 Kudos
Reply

1,481 Views
opener
Contributor I
Do i need to define the functions that range as FAR function?
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III
Hello

Not if you are building in banked memory model (option -Mb).
In banked memory model all functions are supposed to be located in banked flash (i.e. they are invoked with CALL instead of JSR).

CrasyCat
0 Kudos
Reply

1,481 Views
opener
Contributor I
Hi,
 
can we store any global variable in PAGED RAM? or is there any restriction like, the variables which are only global to that module(localised global) can be stored in PAGED RAM. ie., only variables which are defined static out side the function can be stored in FB or FC pages of the RAM?
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III
Hello
 
You can store any global variable in PAGED RAM. Just make sure to define and declare it with the appropriate pragma.
 
CrasyCat
0 Kudos
Reply

1,481 Views
opener
Contributor I
Hi Crasycat,
 
In my application i am defining some variables to be in paged RAM (page FB) through #pragma definition by mentioning __RPAGE_SEG. There are also some variables which declared without __RPAGE_SEG pragma, so it will store in the linear addressing of FD page. How the page shifting will occur in my code, will it work properly or should i need to define all global variables as __RPAGE_SEG?
 
 
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III
BAsically all variables, which are allocated in banked memory must be declared in either a __RPAGE_SEG or a __GPAGE_SEG section.
 
CrasyCat
0 Kudos
Reply

1,481 Views
opener
Contributor I
i am using the GPAGE section by defining __GPAGE_SEG. but there is a warning "cutting value reg between fb1000 to 1000. how to eliminate this warning. i have tried including -D__FAR_DATA in compiling startup.c, still it is throwing same warning.
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III
This happens if you try to assign the address of an object allocated in banked memory to a pointer. You have to use far pointers instead.
 
Would need to see source code where this warning apply to help more.
 
CrasyCat
0 Kudos
Reply

1,481 Views
CrasyCat
Specialist III

Hello

In order to get rid of that message you have to let the startup code know you have global variables in banked memory.

In order to do that add option -D__FAR_DATA to your compiler command line.

Make sure to rebuild the start12.c file with that option activated.

That should do the trick.

CrasyCat

0 Kudos
Reply

1,481 Views
opener
Contributor I
Hi, I have set that compiler option, now that warning message is not coming. Thank you for your support.
0 Kudos
Reply