We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
new compiler V5.05 does not handle an expression: lastrec[2] = (kol_strok / 4); //
and so works: lastrec[2] = kol_strok / 4; //
Thanks, Ralf. It was some kind of magic, because this is a very simple script, not to work. But it was ... to your questions: 1. I use last uvision 5.15 and default compiler (armcc.exe V5.05 update 2 (build 169)). 2. variables and code below: unsigned char lastrec[4]; U16 resint;
resint = 0xDE; // or 222
lastrec[2] = (resint / 4); // lastrec[2] == 0x37 or 55
lastrec[3] = (resint - (lastrec[2] * 4)) + 1; // 222 - (55 * 4) +1 == 3
lastrec[3] *= 0x40; // 3 * 0x40 = 0xC0
lastrec[2] += 0xC0; // 0x37 + 0xC0 = 0xF7
__nop();
3. no errors and messages.
Thank you and best regards, Sergey
You still haven't said what you feel is wrong!!
I thought that is not handled correctly set brackets. Therefore, I check all the brackets and excess removed. That is all.
What is that supposed to mean?!
What, exactly, made you think that?
In what way(s), exactly, did you think the handling was "not correct"?
This code calculates the address of the data access. Then, the address is inserted in the data request command. After receiving the data I have seen the incorrect data - address formed properly.
I have carefully looked at the code and see the unnecessary brackets here are:
lastrec [2] = (resint / 4);
and such
lastrec [3] = (resint - (lastrec [2] * 4)) + 1;
I removed the brackets and it worked.
Perhaps you can provide a complete test example that shows the array content via a printf() for the two cases you've identified. Use the PRE tags when posting source code, see "Posting Tips"
Ideally post a link to a zipped project.
I'm not seeing any casting or precedence issues in the fragments you've provided thus far, but perhaps I'm missing some context here.
I continue to test the project. Recently, the situation with the failure of repeated data. Probably nothing to do with braces ... Let me get a stable result and be sure to let you know