And if you want to use the PtoX() utilities that I
previously emailed to this list, you'll also want the
strcpy_iPtoX().
This function is an INDIRECT string copy for ARRAYS
of STRINGS in P-memory, where both the pointer and the string data are both
stored in P-memory.
void test( void )
{
char
str[30];
strcpy_iPtoX( str,
&ErrorMessages[2] );
...
}
Regards,
William C.
Yochum
Microwave Data Systems Inc.
Principal Eng./Software 175 Science
Parkway Phone:
(585) 242-8319
Rochester, NY 14620 FAX: (585) 241-5590
USA
You
also need to declare the data as constants
const char * const
ErrorMessages[] = {"Error string 1", "Error string 2", ..., "Error string
N"}
----- Original Message ----- From: "ra"
<r...@gmx.net> To: <m...@yahoogroups.com> Sent: Wednesday,
September 22, 2004 2:49 AM Subject: [motoroladsp] strings in p-ROM for
56F8300/E> Hello again > > The previously posted advice works
fine for non-string data, and by > defining a separate linker section
one can place constants in P-ROM: > > in the C source file,
define the section and open it: > >> #pragma define_section
mysection ".mysection.text" RX >> >> #pragma section
mysection begin > >> const int SomeIntegers[] = {0,1,5,3} > >> #pragma section mysection end > > And in
the linker command file add that section to the p-code: > >>
* (.mysection.text)> But when I try this with strings, only their pointers go
into p-rom, > and the string space itself still gets placed in the
data.char section > in data flash. > > I.e., putting
this between the "mysection" pragmas, >> const char * ErrorMessages
[] = >> { >> "Welcome to Wind
Genie DSP", >> "TRBLE
MODE ERR", >> "DATA
ERROR", >> "DATA
CORRUPTED", >>
"DISPLAY ERROR", >>
"MEMORY ERROR", >>
"INVALID PARAMETER" >> }; > >
only a seven-word array "ErrorMessages" with pointers to the strings >
goes into p-rom, whereas the data.char still goes into data-rom. > > Is there any trick to move the strings into p-rom, too? > > This is for a 56F8346 processor, which doesn't use the "rodata" > described in app note AN1952. > > Many thanks in advance
for advice! > Robert Imhoff> > >
_____________________________________ > Note: If you do a simple "reply"
with your email client, only the author > of this message will receive
your answer. You need to do a "reply all" if > you want your
answer to be distributed to the entire group. > >
_____________________________________ > About this discussion group: > > To Join: m...@yahoogroups.com > > To
Post: m...@yahoogroups.com > > To Leave:
m...@yahoogroups.com > > Archives:
http://www.yahoogroups.com/group/motoroladsp > > More Groups:
http://www.dsprelated.com/groups.php3 > > Yahoo! Groups Links
_____________________________________ Note: If
you do a simple "reply" with your email client, only the author of this message
will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.
_____________________________________ About this discussion group:
To Join: m...@yahoogroups.com
To Post:
m...@yahoogroups.com
To Leave: m...@yahoogroups.com
Archives: http://www.yahoogroups.com/group/motoroladsp
More Groups:
http://www.dsprelated.com/groups.php3
|
// src = pointer to source char in P memory
// dst = pointer to destination char in X memory
asm void PtoX(char* dst, char* src)
{
//dst is in r2
//src is in r3
move P:(r3)+,r3
move r3,X:(r2)+
rts
}
// src = pointer to source string in P memory
// dst = pointer to destination string in X memory
void strcpyPtoX(char* dst, char* src)
{
do {
PtoX( (void *)dst, (void *)src);
src++;
} while (*dst++ != '\0');
}
// src = pointer to pointer to source string in P memory
// dst = pointer to destination string in X memory
//
// This function is useful for referencing ARRAYS of strings
// stored in Program Memory. It first copies obtains the pointer
// to the desired string, then copies the string itself.
//
void strcpy_iPtoX(char* dst, char** src)
{
char * tmp_ptr;
PtoX( (void *)&tmp_ptr, (void *)src );
strcpyPtoX( dst, tmp_ptr );
}
|