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

problem with const struct array

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



Joined: 28 Jul 2004
Posts: 32

View user's profile Send private message

problem with const struct array
PostPosted: Wed Sep 01, 2004 1:12 am     Reply with quote

is the constant struct array battery_dat[] too big for ccs??
my program works fine until i call the line:
Code:
{"data.........9","mAh",9,1,900,9},

Code:
char to_print[20];

typedef struct {
   char data_name[20];
   char unit[6];
   int address;
   short read_type;    //same as int1
   long _100_percent;
   int marker;
}bat_data;

//#org 0x1800,0x1fff
const bat_data battery_data[]=
{{"data.........1","mAh",1,1,100,1},
 {"data.........2","V  ",2,1,200,2},
 {"data.........3","mAh",3,1,300,3},
 {"data.........4","V  ",4,1,400,4},
 {"data.........5","mAh",5,1,500,5},
 {"data.........6","V  ",6,1,600,6},
 {"data.........7","mAh",7,1,700,7},
 {"data.........8","V  ",8,1,800,8},
 {"data.........9","mAh",9,1,900,9},
 {"data........10","V  ",10,1,1000,10},
 {"data........11","mAh",11,1,1100,11},
 {"data........12","V  ",12,1,1200,12},
 {"data........13","mAh",13,1,1300,13},
 {"data........14","V  ",14,1,1400,14},
 {"data........15","mAh",15,1,1500,15},
 {"data........16","V  ",16,1,1600,16},
 {"data........17","mAh",17,1,1700,17},
 {"data........18","V  ",18,1,1800,18},
 {"data........19","mAh",19,1,19000,19},
 {"data........20","V  ",20,1,20000,20}};

lcd_write_instruction(line_1);
strcpy(to_print,battery_data[position-1].data_name);
printf(lcd_write_data,"%s",to_print);
printf("%4u%s\n\r",position,to_print);

lcd_write_instruction(line_2);
strcpy(to_print,battery_data[position-1].unit);
printf(lcd_write_data,"%4u%s",position,to_print);
printf("%4u%s\n\r",position,to_print);



the output on the lcd and the hyperterminal (rs232) is:

when position is 7:

7data.........7
7mAh

when position is 8:

8data.........8
8V

when position is 9:

9data....data.........
9.1


i tryed the
Code:
#org 0x1800,0x1fff
before the const struct but the problem is still the same....
Ttelmah
Guest







PostPosted: Wed Sep 01, 2004 3:17 am     Reply with quote

1) What chip?.
2) What compiler version?.
3) Why is 'data_name' declared as 20 bytes long, when the longest strng only needs 15 locations?.

Best Wishes
kloppy



Joined: 28 Jul 2004
Posts: 32

View user's profile Send private message

PostPosted: Wed Sep 01, 2004 7:58 am     Reply with quote

1) 16f876
2) pcm 3.206
3) that's the max i'll ever use with this program (i took 15 just to be sure that data_name is not longer than 20 bytes)
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