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

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



Joined: 15 Mar 2004
Posts: 33
Location: Swiss

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

problem with const
PostPosted: Mon Mar 15, 2004 1:32 am     Reply with quote

I just started with CCS and got confused with this code

char const send_clientlogin[]= "clientlogin";//--Ichip variable, login of client
char const send_clientpassword[]= "clientpassword";//--Ichip variable, password of client
char const send_turnon[]= "turnon";//--Ichip variable, turn on the power flag
char const send_workaddtime[]= "workaddtime";//--Ichip variable, continue working mode of the server flag
char const send_clientpasswordflag[]= "clpwop";//--Ichip variable, enable/disable client login and password flag
char const send_clientpageflag[]= "clientpageflag";//--Ichip variable, client page flag


void test (char arr){
printf("AT+I%S\n\r",array);
}

main {

test (send_clientlogin);

}


I have a lot of constants strings that I define in ROM. How correctly send ROM constants as a parameter to the function.
When I define so

char const send_clientpasswordflag[]= "clpwop";//--Ichip variable, enable/disable client login and password flag
char send_clientpageflag[]= "clientpageflag";//--Ichip variable, client page flag

void test (char arr){
printf("AT+I%S\n\r",array);
}

main {

test (send_clientpasswordflag);
test (send_clientpageflag);

}



The function with const doesn’t work right. What’s a problem and how to be in this case?
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 15, 2004 1:49 am     Reply with quote

Quote:
I have a lot of constants strings that I define in ROM. How correctly send ROM constants as a parameter to the function.

http://www.ccsinfo.com/forum/viewtopic.php?t=18038&highlight=constant+string
http://www.ccsinfo.com/forum/viewtopic.php?t=6285&highlight=constant+string
http://www.ccsinfo.com/forum/viewtopic.php?t=592&highlight=constant+string
Guest








PostPosted: Mon Mar 15, 2004 3:01 am     Reply with quote

I found That theres no support of dirrect adressing to ROM very bad
I have a lot of daclaration of CONST in ROM and I need to send them to RS232 a lot of times in different part of program
So I do in this way
char code send_clientpageflag[] ="blablabal";
char code send_empty_line[] ="xxxxxxl";

printf("AT+I%S='%S'\n\r",send_clientpageflag,send_empty_line);

or
in this way

strcpy(arr1,send_clientpasswordflag);
strcpy(arr2,send_a);
send_ATComm(arr1,arr2);

where
void send_ATComm(char array1,array2){
while (timed_getc(500)!=0x87);
printf("AT+I%S='%S'\n\r",array1,array2);
}

both solution gave me a lot of extra code. Till 10KB!!!!
I used Keil for Atmel and I have no problem with ROM adressing!!!

Is there any optimasation
Ttelmah
Guest







PostPosted: Mon Mar 15, 2004 4:43 am     Reply with quote

Anonymous wrote:
I found That theres no support of dirrect adressing to ROM very bad
I have a lot of daclaration of CONST in ROM and I need to send them to RS232 a lot of times in different part of program
So I do in this way
char code send_clientpageflag[] ="blablabal";
char code send_empty_line[] ="xxxxxxl";

printf("AT+I%S='%S'\n\r",send_clientpageflag,send_empty_line);

or
in this way

strcpy(arr1,send_clientpasswordflag);
strcpy(arr2,send_a);
send_ATComm(arr1,arr2);

where
void send_ATComm(char array1,array2){
while (timed_getc(500)!=0x87);
printf("AT+I%S='%S'\n\r",array1,array2);
}

both solution gave me a lot of extra code. Till 10KB!!!!
I used Keil for Atmel and I have no problem with ROM adressing!!!

Is there any optimasation

Yes.
If you only want to 'send' the strings (not address them), there is a super 'extra' in the CCS code, to help with this. If you write a routine like this:
Code:


void send_byte(int8 ch) {
    do_something_with_a_character_here(ch);
}

Then this routine can be called with a constant string as:
send_byte("A constant string");

or

send_byte(name_of_a_constant_string);

and the code will automatically call the single character routine for each character in the constant string. This is how you can use 'putc("A constant string");
This produces fast/tight code, and provided you only want to deal with such strings 'sequentially', not to do random access, works fine.

Best Wishes
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