AnsweredAssumed Answered

Multiplication Problem in Xgate.

Question asked by Nycil Paul on Oct 20, 2010
Latest reply on Oct 21, 2010 by Nycil Paul

I am currently facing a multiplication problem in my Xgate ISR routine. In one of the PIT interrupts , I have written a statement for multiplyiing a variable and #define. The Problem now is , the value is not getting updated correctly.


eg:My ISR routine which calls a function FadeOut() - its defined below

#define CLOCK_MHZ 50 ( done in Xgate.h)


interrupt void Xgate_PIT3(void) {
    static unsigned char count1s =0;
     p_D_PITTF.p_S_Bits_t.ptf3_u1 = 1;
    if(count1s >= 60) {
      p_D_PITCE.p_S_Bits_t.pce3_u1= 0;
      p_D_PITINTE.p_S_Bits_t.pinte3_u1= 0;   


 void FadeOut(){

      unsigned long MulRegVal = 0;

      MulRegVal = CLOCK_MHZ * (unsigned long)ChargingDutyCycle_u16;  

      if(MulRegVal > 256){

          p_D_PITMTLD0.byte_u8 = 256-1;        
          p_D_PITLD1.word_u16 =  ((MulRegVal/256)-1);

         p_D_PITMTLD0.byte_u8 = (MulRegVal-1);
         p_D_PITLD1.word_u16 = 0;


say ChargingDutyCycle_u16 = 250

Here the varible MulRegVal does not get the value (50*250) ... but only 250 ...

And additionally , when the statement the executed in the TRUE TIME SIMULATOR, and stepped in one step further, it goes into a function called LMULU(). I have defined the LMULU() as


void LMULU{


Why is this function being called? Why  is not the value being updated? When I removed the function, its gievin compilation error saying that particular function is missing.

Please Help

Thanks in Advance