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.

CCS/MSP-TS430DA38: MSP430F2252

Part Number: MSP-TS430DA38
Other Parts Discussed in Thread: MSP430F2252

Tool/software: Code Composer Studio

HI SIR,

i have run UART sample code from ti resource explore .."sizeof string1 - 1" in this line sizeof variable name with - 1 ..actually we are call sizeof funtion just return size of (int (16), char(8), etc..) .but here sizeof varible name subtract 1 ?which one can subtract value or datatype(like int , char, etc..) SAMPLE CODE link  from ti resource explore/msp430f2252/software/device/msp430f2252/peripheral example/ register level/UART_007 EXAMPLE ..CAN YOU CHECK SIR..

THANKING YOU

SIRU

  • That source file includes these lines ...

    char string1[8];
    
    /* many lines later, inside a function */
    
       if (j > sizeof string1 - 1)

    Part of the confusion arises from how the last line is written. This is equivalent, but a bit clearer ...

       if (j > sizeof(string1) - 1)

    The built-in operator sizeof returns the size, in bytes, of its argument.  In this case sizeof(string1) evaluates to the value 8.  So, after all the constant expressions are evaluated, this is the same as ...

       if (j > 7)

    Thanks and regards,

    -George

  • George,
    It took me 2-3 minutes to find an answer and I gave up.
    Your job is really impressing!
  • thank you so much for given result.

    and small dought j value can not get here i think string[8] = string[j] so j=8 it s right sir?

    then start condition apply like if(j > sizeof string1 -1) 

    thank you sir,

    siranjeevi.m

  • siranjeevi mahadevan said:
    i think string[8] = string[j] so j=8 it s right sir?

    No, it is not right.
    If your string is "AAAAAAAA" then
    string[7] == string[j] for 0 <= j < 8

    Moreover, your string declaration
    char string1[8];
    means that both i and j indexes cannot axceed 7 to access string1 data.

    siranjeevi mahadevan said:
    then start condition apply like if(j > sizeof string1 -1) 

    if(j > sizeof string1 -1) means that a string1 is full of data and that this data should be transmitted