??? 12/15/12 07:15 Read: times |
#188994 - Arrays to Structures |
Hi
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]; }COS[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; 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]; }COS[10]; 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.. |
Topic | Author | Date |
Arrays to Structures | 01/01/70 00:00 | |
Coincidence | 01/01/70 00:00 | |
re above | 01/01/70 00:00 |