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.

MSP430FR2433: Msp430 i cant multiply by 32

Part Number: MSP430FR2433

Hello everyone,

i am writing a code on msp430fr2433 and i am not much familiar with fr2433.

i am having difficulties about using some operands like shift and multiply.

i have an example block of code here:

void write(uint8_t GPIO,uint64_t pin,uint16_t addr,uint8_t * data,uint16_t datasize)
{

uint32_t myData = (addr * 32);
// multiply by 32 does not work.


uint32_t myData = (addr * 2);
myData = (myData * 16);
// i workaround the problem like this


}

i pass an 0x1100 as an addr parameter. i assume other parameters are not important for example.

when i multiply with 32 that results 0x2000, it should be 0x22000. i dont know why.

but when i try to multipy with 2 and then 16 that works. result is 0x22000.

i tried to shift operand but that is not working also. as i researched msp430fr2433 has not a multiple shift operand. Seem like it cant shift variables more than 1 bit in one cycle.

Still i dont understand why cant i multiply number with 32.

Thank you in advance 

  • > uint32_t myData = (addr * 32);

    To do this, "addr" is promoted to an "unsigned", which is 16 bits on the MSP430, then multiplied by 32 (top-truncating the result) then promoted to a uint32_t. (This would be different on a 32-bit CPU, where "unsigned" is 32 bits.) Try instead:

    > uint32_t myData = (addr * 32UL);

    or if you prefer:

    > uint32_t myData = ((uint32_t)addr * 32);

**Attention** This is a public forum