CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

#locate to place a struct....

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

#locate to place a struct....
PostPosted: Wed May 14, 2014 11:00 am     Reply with quote

I have a program, already written & working, but I am probably going to tweak it a bit to make it execute a bit faster.

The problem I'm having is that, for readability, I extensively use structs to separate & identify two different serial ports/streams/links. I'd like to locate a specific buffer (a transmit buffer) in a pair of structs to the DMA RAM, but of course this produces an error.

I think I already know the answer, but I'll ask anyway: is there any way to force the compiler to locate a portion of a struct to a specific location in RAM?

What I want (but I suspect to be impossible):

Code:
#locate remote_bus.tx_buffer = 0x7800
#locate local_bus.tx_buffer = 0x7a00


What I'm dreading I'll have to do is remove the tx_buffer from the struct and end up doing things like this:

Code:
#locate remote_tx_buffer = 0x7800
#locate local_tx_buffer = 0x7a00
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Wed May 14, 2014 11:45 am     Reply with quote

The short answer is no you cannot locate only a portion of a struct to a different section from the rest of the struct. struct memory is contiguous.

One option you might try is to do what you dread, but in your struct use pointers to those buffers:

Code:

   
#locate remote_tx_buffer = 0x7800
#locate local_tx_buffer = 0x7a00

typedef struct{
   unsigned int8 *tx_buffer;
   unsigned int8 var1;
   unsigned int8 var2;
}  bus_type;

bus_type remote_bus = {
   &remote_tx_buffer[0],
   0x00,
   0xff
};



That way your struct can have any memory address, but you will always point to your specific location via the pointers
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu May 15, 2014 8:49 am     Reply with quote

Thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group