Hi, All !

It looks like I have found a bug.

Here is an extract from the source (for more see attachment):

uint32_t CalcStepTime(uint8_t s)
{
uint32_t n=0;
long a;
   FeedAcc-=48000L*2560;
   if(breaking)
   {
      a=-MaxdV;
   }
   else if(Feed<cframe.Feed)
   {
      a=MaxdV;
   }
   else a=0;
   do
   {
      Feed+=a;
      if(a>0 && Feed>=cframe.Feed)a=0;
      if(Feed<0){ Feed=0; return n; }
      n++;
   }while(Add(Feed,FeedAcc)>=0);
   return n;
}



And here is a piece of listing:

  56:bug.c         ****       if(a>0 && Feed>=cframe.Feed)a=0;
GAS LISTING C:\DOCUME~1\9335~1\LOCALS~1\Temp/ccEdbaaa.s    page 5


 172                 .stabn 68,0,56,.LM8-CalcStepTime
 173                .LM8:
 174 0040 0C4A        mov r10, r12
 175 0042 0D4B        mov r11, r13
 176 0044 1C83        sub #llo(1), r12
 177 0046 0D73        subc #lhi(1), r13
 178 0048 0638        jl .L9
 179 004a 3E87        sub @r7+, r14
 180 004c 3F77        subc @r7+, r15
 181 004e 2782        sub #4,    r7 ; restore r7  <<restoring r7 in a such
way will destroy comparison result !!!!!!!
 182 0050 0228        jlo .L9
 183 0052 0A43        mov #llo(0), r10
 184 0054 0B43        mov #lhi(0), r11
 185                .L9:

I used my own build from the CVS sources from 31.12.03.

All the best !
Bye.
#include <msp430x14x.h>
#include <signal.h>
#include <sys/inttypes.h>

#define Add(A,B) ({ int r;\
                     asm volatile("add.w %A[a],%A[b]        \n"\
                                  "addc.w %B[a],%B[b]       \n"\
                                  "rrc.w %[c]"\
                                              : [c] "=r" (r), [b] "=rm" (B)     
        \
                                              :  "[b]" (B) , [a] "rm" (A));     
\
                     r;})

#undef N
#undef Z


//Struct for the frame data 
struct  FRAME
{
uint8_t SX,SY,SZ;    //Determines axis steps direction (ignored for G0)
long X,Y,Z;          //Coordinate parameters (direct coordinates for G0, 
normalized for others)
uint32_t N;          //Number of steps (ignored for G0)
uint32_t Feed;       //Feed rate mm/min x 2560
uint8_t func;        //Function code
};

//Data for the current and next frames
struct FRAME cframe,nframe={1,2,3,100000UL,100UL,100UL,200,2400UL*2560,1}; 
//for G0 testing

#define MaxdV 38  // MaxA/80000*1000*60*2560=MaxA*1920

uint8_t G9=0;

long Feed=0; 
uint8_t breaking;

static long FeedAcc=0; //Feed rate intergrator

uint32_t CalcStepTime(uint8_t s)
{
uint32_t n=0;
long a;
   FeedAcc-=48000L*2560;
   if(breaking)
   {
      a=-MaxdV;
   }
   else if(Feed<cframe.Feed)
   {
      a=MaxdV;
   }
   else a=0;
   do
   {
      Feed+=a;
      if(a>0 && Feed>=cframe.Feed)a=0;
      if(Feed<0){ Feed=0; return n; }
      n++;
   }while(Add(Feed,FeedAcc)>=0);
   return n;
}

Reply via email to