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 support@ccsinfo.com

Struct of structs

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



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

Struct of structs
PostPosted: Tue Mar 09, 2004 9:42 am     Reply with quote

Hi All
Does a struct that contains structs all have to fit into a single bank of memory?

I seem to run out to memory with an aray of structs or struct of structs, but if I instantiate them seperatly they compile.
I am using pcm 3.184/mplab6.40 and a PIC 16F877A
Code:

struct  packet{     // Header(first 5 bytes), data(up to 26 bytes), chksum           
  BYTE rx_DA;       // Desgination address recieved
  BYTE data_size;   // Number of bytes. NOT counting header and chksum
  BYTE function;    // Function code of packet         
  BYTE sequence;    // This is the n packet of the total             
  BYTE packet_total;// Total number of packets in message             
  BYTE data[MAXDATA];// Data, size is the number of bytes
  BYTE rx_chksum;    // A checksum over the entire pkt.
  BYTE calc_chksum;  // This checksum is calculated as data is recieved
  //////////////////////////////////////////////////////////////////
  BOOLEAN done; // FLAG, 1=all data has been recieved.
  BOOLEAN good; // FLAG, 1=chksum is corect AND dest==my_address, fctn code is a valid function
  //////////////////////////////////////////////////////////////////
};            // Define 4 packets of buffer space. pkt[0]->pkt[3]
  struct packet pkt0;
  struct packet pkt1;
  struct packet pkt2;



Has anyone done something simulare to this?
I want to define a buffer with 3 packets.
SteveP



Joined: 26 Mar 2004
Posts: 1
Location: Dartford, UK.

View user's profile Send private message

Structs in Structs
PostPosted: Fri Mar 26, 2004 11:07 am     Reply with quote

I have a similar programmin requirement at the moment and have found that the limit is caused by the RAM block size limit. Nothing can be done but define each struct individually as you have done.

Not very elegant, but gets the job done.

Steve.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Mar 26, 2004 5:34 pm     Reply with quote

By looking at the first line of your code your struct size is 31 bytes (although the actual struct appears to be bigger). The biggest memory bank is 96 bytes, so as long as you keep your struct size under 32 you should be able to place an array of 3 in one bank. Try this:

struct packet pkt[3];
#locate pkt=0x190 //Put the array at the very beginning of bank 2
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