avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] use of specifin RAM location


From: Eric Weddington
Subject: Re: [avr-gcc-list] use of specifin RAM location
Date: Tue, 29 Nov 2005 08:48:28 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

David Kelly wrote:


The cleanest way to pull this off would be to lay a structure on the
memory-mapped device and allocate it in a named section. See
http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Variable- Attributes.html#Variable-Attributes

Then in the linking stage define the location of the FPGA something like
this in Makefile:

LDFLAGS= -Wl,-Map,address@hidden \
    -Wl,--section-start=.eeprom=0x00810001 \
    -Wl,--section-start=.fpga1=0x6000 \
    -Wl,--section-start=.hsa2d=0x7000 \
    -Wl,--section-start=.sram=0x2000

Just use the __attribute__ to tag variables as section .sram and the
compiler will find places for them if you don't care about the order.

... Depending on your definition of "cleanest way". ;-)

If the FPGA will be updating these memory locations indpendent of the code, then these will act a lot like processor registers. So, firstly, you'll want to make sure that these memory locations are marked as "volatile".

You can declare your variables similarly as registers are declared:

#include <stdint.h>
#define VARIABLE (*((volatile uint8_t *)0x1234))
...
VARIABLE = 0x01;
uint8_t foo = VARIABLE;

If you want to declare an array of uint8_t, then don't derefence the pointer in the definition:

#include <stdint.h>
#define VARIABLE ((volatile uint8_t *)0x1234)
...
VARIABLE[1] = 0x01;
uint8_t foo = VARIABLE[1];


HTH
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]