Technical discussions about Freescale (Motorola) DSPs (including the DSP56000, DSP56300, DSP56600, 56800 DSPs).
|
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 |
|
|
|
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" <> To: <> 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 > > > _____________________________________ > /groups.php3 > > Yahoo! Groups Links |
|
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.
|
|
// 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 ); } |