Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Praveen Mude
12/15/12 00:15
Read: 1440 times

#188994 - Arrays to Structures

We are using 8052 in our project. We are using the following:

128K EPROM (Code Banking with 2 code banks).
64K External RAM (with Battery-backup).
MAX 232 IC for serial communication.
Keil Compiler & PC-Lint ver 9.0

In the program code, we defined many 2-dimensional arrays. One such array is as shown:

        unsigned char xdata feature_group[10][20];
	unsigned char xdata feature_level[10][20];

	struct classofservice
		unsigned char a_digit_count;
		unsigned char d_digit_count;
		unsigned char cs_denied[12][10];
		unsigned char cs_allowed[12][10];



These arrays are cleared and loaded with code-related data in default conditions. Values in these arrays will be unaffected upon system startup.

At times, we checked the data in these arrays using the printing commands on serial port. We found some garbage data occurence, which disturbs the system fuctionality, and default data needs to be loaded again. The system works fine for a few days, and finally, we need to do the entire system default.

Recently, we came across some articles related to 2-dimensional array usage, and substituted the arrays with structures as shown:
        typedef struct feature_group_index
		unsigned char feature_group[20];
		unsigned char feature_level[20];

	FG	xdata feature_data[10];

	struct cosList
		unsigned char cs_denied[10];
		unsigned char cs_allowed[10];

	typedef struct classofservice
		unsigned char a_digit_count;
		unsigned char d_digit_count;
		struct cosList cosAD[12];



The performance of the system is stable as of now.

As per the results I noticed and explained, is this code conversion (arrays to structures) a better solution to avoid the garbage in memory upto some extent?

Is structure nesting a good practice in C coding as per the 8052 standards?

Kindly Suggest..

List of 3 messages in thread
Arrays to Structures       Praveen Mude      12/15/12 00:15      
   Coincidence      Andy Neil      12/15/12 05:22      
      re above      Erik Malund      12/15/12 08:31      

Back to Subject List