This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LM3S1608

Hello,

new compiler V5.05 does not handle an expression:
lastrec[2] = (kol_strok / 4); //

and so works:
lastrec[2] = kol_strok / 4; //

Parents
  • this works: lastrec[2] = resint / 4; // resint == 0xDF __nop(); __nop(); //lastrec[3] = resint - (lastrec[2] * 4) + 1; // lastrec[3] = resint - ((resint / 4) * 4) + 1; // __nop(); __nop(); lastrec[3] *= 0x40; // lastrec[2] += 0xC0; //

    this not works: lastrec[2] = resint / 4; // lastrec[3] = resint - (lastrec[2] * 4) + 1; // lastrec[3] *= 0x40; // lastrec[2] += 0xC0; //

    P.S.: my name is Sergey

Reply
  • this works: lastrec[2] = resint / 4; // resint == 0xDF __nop(); __nop(); //lastrec[3] = resint - (lastrec[2] * 4) + 1; // lastrec[3] = resint - ((resint / 4) * 4) + 1; // __nop(); __nop(); lastrec[3] *= 0x40; // lastrec[2] += 0xC0; //

    this not works: lastrec[2] = resint / 4; // lastrec[3] = resint - (lastrec[2] * 4) + 1; // lastrec[3] *= 0x40; // lastrec[2] += 0xC0; //

    P.S.: my name is Sergey

Children
  • (Please remove code that is commented out from your snippets)

    Testing that code also did not result in an error.

    For a closer investigation it is required to know:
    - the toolchain and version in use (Help - About µVision)
    - the definitons of all variables
    - the error message your project results in (screenshot of Build Output window)

    Thank you and best regards,
    Ralf

    R.Kopsch
    Senior Applications Engineer
    ARM Germany GmbH

  • 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