This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: CCSTUDIO-MSP
Tool/software: Code Composer Studio
Hello, I recently switched to CCS 10.1.1.00004 and now I encounter a problem that I cannot fix. I can duplicate the problem by a minimal CCS managed example. Please see below. At the marked line, the array address gets lost. The array address is held here in a register.
After execution, the register contains a wong value. My old GCC compiler does it right, it uses RAM and no register at the point. Maybe I'm doing something wrong. Could someone please it try out and possibly
advice? The optimization is completely switched off, the compiler is TI v20.2.3.LTS, the CPU is MSP430F2274. Many thanks. #include <msp430.h> / ** * main.c * / static void test_list (unsigned char * data, unsigned int len) { unsigned long ul_id; ul_id = (unsigned long) (data [0]); ul_id + = ((unsigned long) (data [1]) << 8); // << after that the array address is wrong !! ul_id + = ((unsigned long) (data [2]) << 16); ul_id + = ((unsigned long) (data [3]) << 24); } void test () { unsigned char buffer [8] = {0,1,2,3,4,5,6,7}; test_list (buffer, 8); } int main (void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer while (1) { Test(); } return 0; }
Please show the build options exactly as compiler sees them. Please copy and paste the text, and do not use a screen shot.
Robert Tyrakowski said:At the marked line, the array address gets lost.
I'm not sure what you mean. How do you know the array address is lost? What do you look at? Is the result computed into ul_id correct?
Thanks and regards,
-George
Hello George,
The result of ul_id is wrong in the end. I checked it with a debugger and saw
that the correct address of data is in R12 before the add instructions. After the
second add instruction, R12 contains a wrong value. So the rest of the
add commands went wrong, du to wrong address of data in R12.
Hopefully that explains my problem a bit better.
Regards
Robert
The value of ul_id is only half-done, but 0x0100 is correct so far. What does it look like when you're finished?
In the second screenshot, the pointer to data[] is in R15. I'm not sure why you're looking at R12.
Thank you for your help.
You are right, the example is working correctly. I was mislead because the debugger uses R12 for displaying
the array, but if the register changes a wrong area is displayed. So the example does not really reflect
my essential problem in my final program. Their the result of ul_id is finally not correct. It seems I possibly have a problem
with RAM and/or stack size.
Thanks again