declare ram variable at fixed known address

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

declare ram variable at fixed known address

2,068 Views
EdProulx
Contributor I

There is a decent amount of information on how to declare a variable in ram at a fixewd known address - but none is concise or complete.

 

On my MC52259 board (64K ram), I wanted a ram var at say: 0x20000400. It is 0x20 bytes long. I modeled the declaration after similar variables in flash, I get what I want, except the linker fails as the "next var" (as per the lcf linker control file) must be on a 512-byte boundary. So I'd wasting ram unless I put in code for specific use of wha's left in that area.

 

Is there a way to have a small variable of 0x20 bytes at a specified, well-known address without the boundary issue?

 

I assume that I'll have some sort of declaration in the .lcf file, and a #pragma in my main.c module.

 

Ed

Labels (1)
0 Kudos
Reply
3 Replies

991 Views
LordMark
Contributor IV

I would need the same thing and I have the same MCU.


UP! 

0 Kudos
Reply

991 Views
PaoloRenzo
Contributor V

Hi

 

As an starting point, here are the steps for the mcf5213- very similar

 

1. Download dBUG source ode

 

http://www.freescale.com/files/netcomm/software/app_software/dbug_rom_monitors/M5213EVB_DBUG_SRC.zip...

 

2. Look for mwerks.h, flash.lcf

 

3. Inside LCF:

 

        *(.relocate_code)
        *(.relocate_const)
        *(.relocate_data)

 

4. Inside mwerks.h:

 

#pragma define_section relocate_code ".relocate_code" far_absolute RX
#pragma define_section relocate_data ".relocate_data" far_absolute RW
#pragma define_section relocate_const ".relocate_const" far_absolute R
#define __relocate_code__   __declspec(relocate_code)
#define __relocate_data__   __declspec(relocate_data)
#define __relocate_const__  __declspec(relocate_const)

 

5. For a variable is used as follows:

 

__relocate_data__
char ovbuffer[60];

 

__relocate_const__ char
erase_flash[] = "Erasing Flash...";

 

6. For a function:

 

__relocate_code__
static uint8
dldbug_getchar(void)
{    ...    }

 

Hope this gives you a hint, also the AN3521SW has a source code.

 

 

0 Kudos
Reply

991 Views
MadhuBhaskar
Contributor I

Hi Every body,

I am working on MCF5213 controller.

I have a requirement where in i should use, some part of CPU Flash should be used as RAM.

Will any one guide me in this implementation

 

Thanks in advance

0 Kudos
Reply