AnsweredAssumed Answered

MC56F8023 dealing with UWord32

Question asked by sandrom on Aug 8, 2017
Latest reply on Oct 4, 2017 by sandrom

Hello all,


I'm using MC56F8023 with CW 10.7, I see examples that use 32 bit variable (declared by Word32 and UWord32).

I have some strange behavior using them, this is the code I use:


void function (void) {

   UWord32 temp = 0;
  UWord32 temp0 = 0;
  UWord32 temp1 = 0;
  temp1 = 2053;
  temp0 = (UWord32)(temp1 * 330);
  temp = temp0 >> 12;



I use temp variables here as an example. What happens is that, during debugging, temp0 variable take absurd values (usually 216268800), and I dont understand why. The original code doesnt use fixed values obviously, here are only for example.

Someone can explain me what happens? Should I not use 32-bit variables? I know the microcontroller is a 16-bit one, but if CW let me use 32bit...


EDIT: It is a interrupt-related issue, because if I disable them before operations, all is ok. But I would disable interrupt for stuff like this...what should I do? My only problem is that the multiplication could overflow the 16-bit.


Thanks in advance for help!