![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Vovachess
Joined: 15 Mar 2004 Posts: 33 Location: Swiss
|
problem with const |
Posted: Mon Mar 15, 2004 1:32 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Mar 15, 2004 3:01 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Mar 15, 2004 4:43 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|