AnsweredAssumed Answered

usign MC9S12DP256BD micro and codewarrior 5.1, a variable i declared keeps doubling in value every other time through a function and for no reason. not sure how to fix it?

Question asked by Kevan Sherwood on Nov 25, 2013
Latest reply on Nov 27, 2013 by Matthew Kendall

I am trying to create an error buffer which sets the amount of time in seconds in which it will delay an error message on my LCD. The second value can be between 1 sec and 99 secs.


code for setting the value works and is fine it lets me change the value:

    case MODE_CHANGE:
      if(param == MOD_MAIN_ERR_BUF_MODE)
        hid_set_LCD_solid(HID_LCD_INT_PARAM |
                          err_buf_val |
                          HID_LCD_0_DP |



once i get the err_buf_val, i do some math to save tha value in seconds:


                  if(min>= err_buf_val <=max)


                  err_seconds = (err_buf_val * 1000000);



the problem is that err_buf_val will be doubled the value entered on the keypad everyother time it runs through the code. for instance if i set the value to 5 seconds then it switches between 5 and 10 seconds everytime through the function. and the err_seconds value will change between 5000000 and 10000000.


if anyone understands than let me know what u think.


err_buf_val is declared as a uint16

err_seconds is declared as a uint32