Thread: creating a data structure at specific memory location in c

  1. #1
    Registered User
    Join Date
    May 2015

    creating a data structure at specific memory location in c

    I'm working on an embedded mcu that has two cores which can both see an area of memory beginning at 0x80000000.

    The ADC is connected to one core and a radio is connected to another. I want to write the data value received by the ADC to this memory address so that the other core can read it.

    Would somebody be able to help me figure out how to do this? The is no micro OS, it is bare metal.

    Would I create a pointer to struct at a specific address?

    I have two values in an array, how would I get them into the struct?
    #define NUM_SAMPLES_POLLED (2)
    uint16_t samples_polled[NUM_SAMPLES_POLLED]

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    How much "bare-metal" is it? Does it have core-specific interrupts you can raise? Atomic memory instructions( LOCK etc )?

    What "struct" are you talking about?
    Devoted my life to programming...

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Which compiler / toolchain are you using?

    This isn't complete, but does show you where you need to start looking.

    This is for GCC

    You start by annotating your data declaration like so
    uint16_t samples_polled[NUM_SAMPLES_POLLED] _attribute__ ((section ("MY_FOO"))) ;
    Coupled with a linker script (see here), you'll be able to place that data at a specific location in the memory map.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. moving file pointer to specific location
    By narendrav in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2015, 09:20 AM
  2. Running Function from specific memory location
    By mshearer123 in forum C Programming
    Replies: 2
    Last Post: 01-27-2010, 11:14 AM
  3. Memory Location
    By SomC in forum C Programming
    Replies: 6
    Last Post: 05-08-2004, 02:54 AM
  4. memory location
    By xlordt in forum C Programming
    Replies: 3
    Last Post: 10-21-2002, 09:39 AM
  5. location specific console colors
    By bennyandthejets in forum C Programming
    Replies: 7
    Last Post: 07-24-2002, 07:32 AM

Tags for this Thread