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/MSP430F5244: Functionality doubt of a controller or IDE

Part Number: MSP430F5244

Tool/software: Code Composer Studio

Hello, I'm using the msp430f5244 with CCS, I'm trying to do a 4byte operation on this two byte controller and IDE , so it's giving me wrong values  please let me know how to do the following operation on the controller.

Thank you.

#define TMR_RUN_MAX_MILLI_SEC              100
#define TMR_TICKS_PER_MS                   4.1
#define TMR_ONE_SEC             	   1000

const uint32_t TMR_CNT_FOR_DEVICE_DETECT          =((120*TMR_ONE_SEC)/TMR_RUN_MAX_MILLI_SEC);

  • Dhananjay J said:
    it's giving me wrong values

    What values it's giving and what values do you expect instead?

  • Hi Dhananjay!

    Plain numbers that aren't declared with a datatype are treated as 16 bit integer values.

    120 * 1000 results in 120000 which is too much for a 16 bit integer. It rolls over. You can write

    #define TMR_ONE_SEC ((uint32_t) 1000)

    or

    ... = ((120 * ((uint32_t) TMR_ONE_SEC)) / TMR_RUN_MAX_MILLI_SEC);

    or

    ... = ((((uint32_t) 120) * TMR_ONE_SEC) / TMR_RUN_MAX_MILLI_SEC);

    Dennis

**Attention** This is a public forum