This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Variables zeroed out when doing simple math

I'm using RTL for my project, and what I am finding is that when I pass parameters (mentioned in another post) and when I do simple math the variables are zeroed out?

What in the world would cause this? I have never seen this, and I am really not sure what could be causing this. Has anyone ever seen this before, and what in the world do I need to do to prevent this?

Here is a snipit of code that is being zeroed:

pMot->STAT.ulPulseWidth = pMot->STAT.ulPulseWidth / 100;

pMot->STAT.ulSysClkPeriod = (unsigned long)(SysCtlClockGet() / PWM_PERIOD_DIV); pMot->STAT.ulPWMPeriod = pMot->STAT.ulSysClkPeriod * pMot->STAT.ulPulseWidth;

Parents
  • What, exactly, is "getting zeroed" ?

    How are you observing this "zeroing"?

    pMot->STAT.ulPulseWidth = pMot->STAT.ulPulseWidth / 100;
    

    You haven't shown the definition of ulPulseWidth - if it's an integral type, is its initial value more than 100?

    pMot->STAT.ulSysClkPeriod = (unsigned long)(SysCtlClockGet() / PWM_PERIOD_DIV);
    pMot->STAT.ulPWMPeriod    = pMot->STAT.ulSysClkPeriod * pMot->STAT.ulPulseWidth;
    


    Similarly.

    And note how to post source code legibly!

Reply
  • What, exactly, is "getting zeroed" ?

    How are you observing this "zeroing"?

    pMot->STAT.ulPulseWidth = pMot->STAT.ulPulseWidth / 100;
    

    You haven't shown the definition of ulPulseWidth - if it's an integral type, is its initial value more than 100?

    pMot->STAT.ulSysClkPeriod = (unsigned long)(SysCtlClockGet() / PWM_PERIOD_DIV);
    pMot->STAT.ulPWMPeriod    = pMot->STAT.ulSysClkPeriod * pMot->STAT.ulPulseWidth;
    


    Similarly.

    And note how to post source code legibly!

Children