creating a pointer to struct at a specific address

Hi,

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]

Thanks

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

An interesting concept that is as old as computing ... shared memory. But, I've never seen it implemented on a dual-uC before. Just for personal reference, is this a custom board you created or a commercially available product? If the latter, I would have surely thought the manufacturer would have provided a few examples.

The problem that I see is that your structure or commonly classed variables must be location specific. GCC does seem to support such a concept: here

Start small with a couple of test programs and just pass an integer .... one uC counting and one uC displaying. Then get a bit more complex.

Ray

If the compiler does not complain, you can always try this:

int *p;

p = (int *)0x80000;

Your biggest problem might be that you need a some mechanism to prevent a value being read while it's being written and verse visa (which would possibly result in invalid data being read).

You need to provide a little more information about the hardware (and the above is not my area of expertise although I think I know the pitfalls).

sterretje:
Your biggest problem might be that you need a some mechanism to prevent a value being read while it’s being written and verse visa (which would possibly result in invalid data being read).
<…>

I read the Op’s post as the intended implementation was for a one-way transfer: write on one side, read on the other. As s/he is dealing with a struct, I suspect that any member element could be either R or W, just not both.

I too asked about the H/W since I would like to know more.

Ray

Even with a single direction transfer there is a risk that a write and a read occur at the same time and one e.g reads a low byte of the previous reading and a high byte of the new reading.

sterretje: Even with a single direction transfer there is a risk that a write and a read occur at the same time and one e.g reads a low byte of the previous reading and a high byte of the new reading.

Yes ... there is that distinct possibility ... One could just add a Boolean to the data-structure and the sender set it to 0 before updating anything and then sets it to "1" ... the receiver could then easily distinguish the flag which would be akin to a semaphore.

Ray

I would think that race conditions are still a risk with your approach. We can do a lot of theory ;) But let's wait for ultrasonicbanana to get back to us.