Microprocessor address space and variables?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hallo,
I must create a memory for a display lcd. This is part of a microcontroller
based on a microprocessor.

I thought to do it using a variable, a matrix:  display[X][Y]  (the software
video memory).

This variable should exaclty stay into micrporcessor address space where I
have
mapped a ram (the hardware video memory) from 0x77200000 to 0x7720FFFF.

In this way, working with my variable I could edit hardware video memory.

But I'm not able... how may I do it?

Many Thanks in Advance
Marco Toschi



Re: Microprocessor address space and variables?

Quoted text here. Click to load it

I assume that you have mapped the video memory correctly with hardware
and now want to know how to use the compiler to map an array to the
video memory.

There are different ways to do this based on your compiler.  Some
compilers have extensions that allow you to specify the location of a
variable.  For others, you can declare it external and specify the
address with the linker.  In some, you might specify that the array goes
into a separate memory segment (using an extension), then use the linker
to specify the load address of the segment.  You may be able to specify
the absolute address in an assembly module and declare it extern in the
C module.  Finally, you could use a pointer instead of a directly
addressed array and initialize the pointer to the video RAM address.

Thad


Re: Microprocessor address space and variables?

Quoted text here. Click to load it


I have tried doing this:

#define HEIGHT ...
#define WIDTH ...

unsigned char *display[HEIGHT][WIDTH] = (unsigned char *)0x77200000;

display[y][x] = ...

But during compilation I receive an error message:

invalid initialize

What could I do?

Many Thanks
Marco



Re: Microprocessor address space and variables?


Quoted text here. Click to load it

Use a one dimensional array
#define LENGTH (HEIGHT * WIDTH)
unsigned char * p_arr =(unsigned char*)0x77200000;
if you want to access the cell (x,y) ,
p_arr[x*HEIGHT + y] =  z;


Re: Microprocessor address space and variables?

Quoted text here. Click to load it

You are declaring display as two-dimensional array of pointers to unsigned
char, which I suspect is not your purpouse.


Quoted text here. Click to load it

Possibly this:

unsigned char (*display)[HEIGHT][WIDTH] = (void*)0x77200000;


   Vadim Borshchev

Re: Microprocessor address space and variables?

Quoted text here. Click to load it

That's not any better than the other inherently unportable solutions
suggested a good deal earlier.  It's a wild guess what an unknown
platform might actually do if you cast a 32-bit integer value to a
pointer type.  So, since you have to do something unportable anyway,
you might as well do it the way that best fits the actual platform.

Anyway, if one really wanted to do it this way, I suggest to forget
about trying to hardwire HEIGHT, and use

    unsigned char (*display)[WIDTH] = (void *)0x77200000;

instead, or, to express the same thing in a more verbose fashion:

    typedef unsigned char t_display_row[WIDTH];
    typedef t_display_row * t_display;

    t_display display = (void *) 0x77200000;

This generates one redirection operation per access to the array less
than Vadim's version, so it has a certain chance of being faster.

Depending on the platform, and the value of WIDTH, the "array of
pointers to display rows" may be more efficient:

    typedef t_display_row * t_display[HEIGHT];

This uses more memory, but the precomputed row pointers may be faster
to use than 2D array indexing, which involves multiplication of one
screen coordinate by WIDTH.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: Microprocessor address space and variables?
On 20 Jun 2005 17:10:20 GMT, Hans-Bernhard Broeker

Quoted text here. Click to load it

Yes, this is the usual out-of-coffee slip of mind.  I shouldn't have
posted today :)

   Vadim Borshchev

Site Timeline