Multiplication Problem in Xgate.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiplication Problem in Xgate.

Jump to solution
1,170 Views
Nycil
Contributor I

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;   
      FadeOut();
    }
    else{
      count1s++;
    }
        
}

 

 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);
       }


      else{
 
         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

Labels (1)
0 Kudos
1 Solution
625 Views
kef
Specialist I

Does your project include ansi_xg*.lib library? LMULU is long*long runtime routine. You should remove LMULU from your code and add required XGATE library.

 

View solution in original post

0 Kudos
6 Replies
626 Views
kef
Specialist I

Does your project include ansi_xg*.lib library? LMULU is long*long runtime routine. You should remove LMULU from your code and add required XGATE library.

 

0 Kudos
625 Views
Nycil
Contributor I

Yes Kef , that could solve the problem. How should I proceed to include that library file in the project? Should I make any changes to the makefile to include the library?

0 Kudos
625 Views
kef
Specialist I

I'm using CW IDE and don't know how to modify makefile. But paths to XGATE libraries are as follows:

<CW root>\lib\xgatec\lib\ansi_xgi.lib  <- no floating point support

<CW root>\lib\xgatec\lib\ansi_xg.lib   <- full library, including floating point runtime

0 Kudos
625 Views
Nycil
Contributor I

Thanks Kef. I dont use CW IDE. So including the library is difficult coz I dont know how. I tried compiling the rtsxgate.cxgate along with the project and but it showed duplicate declaration with rtshc12.c. So I have run out of ideas now. 

Please Help

0 Kudos
625 Views
kef
Specialist I

Duplicates for what symbols? A lot of symbols, or just those few you have defined in your code, like LMUL? If many, then maybe XGATE library is already added? If just a cople, then just remove or rename conflicting objects from your code.

0 Kudos
625 Views
Nycil
Contributor I

I included the library in the prm file and its working perfectly fine.

Thanks Kef .

 

0 Kudos