Personal tools
You are here: Home Forums M32C Reduction timing

Reduction timing

Up to M32C

Reduction timing

Posted by genius2005 at July 22. 2008

hello to everyone

i have to decrease the time which m32c87 has compiled the code;    

i mean this code is being compiled about  30 micro second , i want it to be about 15 micro second or below the same code ,

please help .. 

for(i=0;i<16;i++)
     {
        adcresult2008[i]=adcresultold2008[i]+(adcresult2008[i]-adcresultold2008[i])>>1;
              adcresultold2008[i]=adcresult2008[i];
     }

thanks in advance

Re: Reduction timing

Posted by FrankL at July 22. 2008

Does this code have the correct result?

I think you want to calculate

adcresult2008 = adcresultold2008 + ((adcresult2008 - adcresultold2008)/2);

From the assembler code your example calculates

adcresult2008 = (adcresultold2008 + adcresult2008 - adcresultold2008)/2;

This is a little bit faster:

signed int j;
near signed int adcresult2008[16], adcresultold2008[16];
  for(j=15;j>=0;j--)
  {
    adcresultold2008[j]=adcresultold2008[j]+((adcresult2008[j]-adcresultold2008[j])>>1);
  }

Re: Reduction timing

Posted by genius2005 at July 23. 2008

really sorry,  but  they are being worked  in more time

Re: Reduction timing

Posted by FrankL at July 23. 2008

My debugger said the routine took sometihng around 14µs. And this should include some overhead from the debugger. I did not check with an oscilloscope.

Are you sure you run at maximum speed with 32MHz?

Re: Reduction timing

Posted by genius2005 at July 24. 2008

hello      

i am using   hew  for programming m32c87,

can you  send  the assembler code of the code at below??  pleaseeeeee 

 

       for(i=0;i<16;i++)
          {
           adcresult2008[i]=adcresultold2008[i]+(( adcresult2008[i]-adcresultold2008[i])>>1) ;
          adcresultold2008[i]=adcresult2008[i];
          }

thanks in advance very much

Re: Reduction timing

Posted by genius2005 at July 24. 2008

just assembler codes

Re: Reduction timing

Posted by Calvin Grier at July 24. 2008

When do you take the new A/D reading and stuff it in the array? Is there a reason you need to do all the calculations at once?

You'd be able to eliminate the loop overhead completely, if you did the calculation each time a new value was stuffed in the array.

Re: Reduction timing

Posted by genius2005 at July 24. 2008

thank you very much, i solved  , i decreased 8 mikro second...

 i want to just learn the assemble code of the codes

Re: Reduction timing

Posted by Calvin Grier at July 24. 2008

What did you change to get 8 micro seconds?

Re: Reduction timing

Posted by FrankL at July 24. 2008

If you want to learn assembler codes tell the compiler to include the assembler code in the list files, or tell the compiler to generate assembler sources.

Re: Reduction timing

Posted by genius2005 at July 25. 2008

i decided not to use array and loop,    is there anybody who will change the codes to the assembler codes ,, 

 beside i want to learn  as308  assemble ,,  but i could not learn how i can start to main block as C,

 i mean i can learn command set, but i want to learn how i will allocate ram space, how i can come to main block according to C,

         for(i=0;i<16;i++)
       {
          adcresult2008[i]=adcresultold2008[i]+(( adcresult2008[i]-adcresultold2008[i])>>1) ;
         adcresultold2008[i]=adcresult2008[i];
         }

Re: Reduction timing

Posted by genius2005 at July 25. 2008

for example in  C, we must write first  #include files, #define ,#pragma, variables, then we can pass to main block,,

we do not need to allocate ram , place of variables......   how can we make that until main block in assebler

thanks very much

Re: Reduction timing

Posted by FrankL at July 25. 2008

As I said, just tell the compiler to generate an assembler file of your code. You can see what it does to reserve RAM, how it writes assembler code, all these things.


Re: Reduction timing

Posted by genius2005 at July 25. 2008

thanks very much, but i can not understant what is what,,   i mean what is the assembler structure??

Powered by Ploneboard