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.
I'm working on some firmware for a TMS320F28027 microcontroller. I have a data structure with some structures inside of it. See below for an example (the real structure has more elements which result in a size of 64 bytes). Everything seems to work just fine until I reach a sizeof() size of 64 bytes. If I add one more additional element, the code compiles and programs just fine, but the data inside of the structure is somehow getting corrupted or otherwise adversely affecting the program since it will not run. Looking at the variables in the expressions window doesn't yield any obvious signs of whats going on. Any help would be greatly appreciated.
typedef struct { struct { _iq Test_1; _iq Test_2; _iq Test_3; _iq Test_4; } Example_1; struct { _iq Test_1; } Example_2; struct { uint16_t Count; _iq Test_1; _iq Test_2; _iq Test_3; } Example_3; struct { uint16_t Test_1; uint16_t Test_2; } Example_4; } Example_t;
Thanks,
This is vague. The root cause could be almost anything.
I presume you aware that, on C2000, type char is 16-bits wide. So, when you say 64 bytes, I presume you mean 64 16-bit words.
64 words is the size of a data page. So this might be due to some problem with managing the data page pointer. Try building with the option --disable_dp_load_opt. If that makes no difference, then the problem must be something else. If it causes the code to work, then we have a better idea of what may be wrong.
Thanks and regards,
-George
George,
I will give this a try and let you know the result. I apologize that my original post was vague. It is really hard to say what is going on due to the odd and inconsistent behavior I'm seeing. I can add additional variables in the same source file and declare the two right next to one another with no problems. I will keep you posted.
George,
You suggestion to add the option --disable_dp_load_opt seems to be doing the trick. Tested my code multiple times now with additional elements in the structure. Now if the sizeof() returns a value larger than 64 (words) things seem to be working. I suppose it still begs the question as to why the data pointer load optimization is creating this problem. I'm also curious what the downsides are of running with this option disabled.
I suspect a problem in the compiler is causing the data page register to have the wrong value at some point. The focus now is the find the source file where this is happening, then submit that as a test case for further analysis.
The method for doing that is a fair amount of work. And only you can do it. That's unfortunate, but I don't see another way forward.
Build everything without --disable_dp_load_opt , except for one file. If it fails, then that is not the file. So, try again with a different file. Repeat until it works. Then you have found the file to submit. If you build with CCS, then see this wiki article for how to change build options for just one file.
Thanks and regards,
-George
George,
I have a possible idea where the problem may lie. I will try your suggestion and build the project without the --disable_dp_load_opt except that one file. If this does not work we may have to move forward with disabling the option for now until we have more time to pinpoint the problem. What are the issues if any of proceeding with using the --disable_dp_load_opt. I would assume there are some performance ramifications and maybe others? Do you know what those are?
Drew Westrick said:I would assume there are some performance ramifications and maybe others? Do you know what those are?
Your code will have more instructions to load the DP register than is really needed. This causes your code to be bigger and run slower. Just how much can be known only by taking measurements. It may be so little you don't care. Or it could be a big deal.
Thanks and regards,
-George