View previous topic :: View next topic |
Author |
Message |
bjerkely12
Joined: 04 May 2006 Posts: 5
|
IAR to CCS |
Posted: Tue May 09, 2006 1:27 pm |
|
|
Hi friends,
I'm trying to convert some IAR code to CCS and have confusions with data declarations.For example what can I use in CCS for
__eeprom __no_init <identifier> ;
Thanx in advance, |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Tue May 09, 2006 2:19 pm |
|
|
What does __eeprom __no_init do? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
bjerkely12
Joined: 04 May 2006 Posts: 5
|
|
Posted: Wed May 10, 2006 5:18 pm |
|
|
In CCS manual it says that pointer to constand is not allowed ,ok but how can I handle this
const char *str; |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 10, 2006 5:31 pm |
|
|
You could have a global array in RAM, and copy a string into it
by using the CCS strcpy() function and then pass the address
of the RAM array to your function. Example:
Code: |
#include <16F877.H>
#device *=16
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
char const msg1[]= {"Hello World"};
char const msg2[]= {"ABCD"};
char const msg3[]= {"Last message"};
char string_buffer[96];
void display_message(char *ptr)
{
printf("%s\n\r", ptr);
}
//===========================
void main()
{
strcpy(string_buffer, msg1);
display_message(string_buffer);
strcpy(string_buffer, msg2);
display_message(string_buffer);
strcpy(string_buffer, msg3);
display_message(string_buffer);
while(1);
}
|
Also see this post which uses the switch-case method to work around
the problem of no pointers to constant strings:
http://www.ccsinfo.com/forum/viewtopic.php?t=25483&start=7 |
|
|
|