I want to TX out the string "1234" as below:
Uart1_PutString("1234"); // pass pointer
volatile char *s_pointer; // global variable
void Uart1_PutString(s)
char *s;
{
s_pointer=s; // TX_isr() uses s_pointer to load the string character into TX register as // io.sci1.scidr=*s_pointer;
io.sci1.scicr |= TRANSMITTER_EMPTY_INT; // enable interrupt
}
Problem: the first character tx out is not 0x31 as expected but instead 0x57 incorrectly. I found the xROM was initialized incorrectly by the 56800E Flash Programmer.exe (I can't find the sw version) and USB TAP rev F (see xROM memory screen end of post).
Below are snippets to show the string const was stored in xROM location 0x4000:
From the xMAP file the const "1234" was initialized to xROM (internal data flash) at address 0x4000 with 3 words (6 bytes needed for 4 chars plus terminating NUL) starting form address 0x4000:
From main.asm file, I see string “1,2,3,4” is inititialized:
How do I fix this problem?
Thanks,
Brian
More than a week and my case is still unresolved. Could someone from NXP please help me on this? Basically it only worked when I stored the string const in the program flash, but the tool failed when I wanted to store the string const in data flash memory.
Regards,
Brian
Hi,
Maybe the compiler strips the "1234" because compiler finds out the string is not used.
Anyway, I hope you define a char point and assign the char point by the "1234", then assign the pointer to the api function.
Uart1_PutString();
BR
Xiangjun Rong
"Maybe the compiler strips the "1234" because compiler finds out the string is not used."
This can't be true because if I changed the linker command to use Program flash instead of Data flash then it worked. I would like NXP people to look into this issue and resolve it, because we still want to use data flash for those strings instead of the program flash.
Best,
Brian
Hi,
If you want to save the constant in data flash, it is okay to just add const before the string array.
For example:
const char str[]="ABCD,I am a student\n";
Hope it can help you.
BR
Xiangjun Rong
O.K. so I tried with const array and it’s still wrong:
const unsigned char lens_id[]="1234"; // NOTE: string const is mapped to .x_flash_ROM in linker // command file
Uart1_PutString(lens_id); // pass pointer
Compiled and then view the S-record file shows “1234” string is located at $4008000 or 2004000 word address. This is all correct.
// byte address $4008000 or word address $2004000 holds correct data of $3231 for “1234” string
S30D000800A054E2A21901E708E782
S30B0400800031323334000F97
S70500080000F2
However, after loaded the s-record file with 56800E Programmer the said address holds a different value: $6557
This seems to prove that the compiler is correct but the 56800E Programmer had failed to do the job. Attached is the .S file, and I hope someone can help to load it into the chip (I used 56F8367) and then use View Memory tab to look at data memory location $4000 if it holds $3231 or something else. (Make sure to select memory type X for data instead of the default P for program.)
My IDE tool version:
Brian
Hi, Brian,
I am sorry for the delay.
Regarding your question, I do not find out where you define the constant.
Can you define a message just like:
const char message[]="I am a student\n";
If you define in this way, the message will be saved in flash automatically.
Hope it can help you.
BR
Xiangjun rong
Hi Xiangjun,
String const "1234" was used by function Uart_PutString() :
Uart1_PutString("1234"); //(lens_id); // pass pointer
Are you saying the above code is not enough?
And when checking the main.asm we can see the compiler should initialize the string const at label F1055 as below. Why should I need to define it as you suggested (const char message[]="I am a student\n";)?
Does my code have any syntactic errors?
Best,
Brian
Hi,
The current version of CodeWarrior for DSP56800E is ver8.3, your version is 5.9, can you upgrade to ver8.3? But I do not guarantee that the updation can fix the issue.
As a workaround, can you declare a constant global variable as I have said and transfer the the address to s_pointer.
Hope it can help you
BR
Xiangjun Rong
Hi,
I am sorry, It seems that you use CW for DSP56800E ver8.3, can you post your project here so that I can duplicate it on my board and track the cause? i think it is compiler issue instead of USBTAP.
BR
Xiangjun Rong
Hi Xiangjun,
Here is what I found:
When mapped to x_flash_ROM using linker command file, the S record shows the string const "1234" located at $8000 (byte address) but the code runs wrong. When loaded and viewed with 56800E Flash Programmer’s View-Memory, xdata word address $4000 is not the correct string constant. The S-record seems to be correct, but the View Memory shows wrong value and this could be the proof that the Programmer is bad?
When mapped to .p_flash_ROM_data, the code runs correctly:
S-record shows string at byte address $3CC0: