Hi Susan,
The program is part of a controller for a motor. I have tested it for passing variables, for x and y space being read correctly, and for motor control using addition equations and only positive variables to give a fixed output value. It works fine in all these tests, i.e. the motor spins, at a speed that would be expected from the predicted output value . The problem is that the program I have requires the use of negative variables, but when I input negative variables,in addition to the compiler warning messages, the motor jumps to a high speed then ramps down over 1 to 2 seconds and repeats the cycle. What I expect to happen is for the motor to start smoothly from rest to a desired speed.
here is the part of it in c code
// Declare variables and function //
signed _Fract Gx, Refl; // Variables Gx and Refl
signed _Fract Zout = 0; // return variable Zout
signed _Fract __attribute__((space(xmemory), __aligned__(4))) Rijn[3]= {0.111,-0.12,0.001};
signed _Fract __attribute__((space(ymemory),far,__aligned__(4))) Vs[3];
extern void ZIJ(void);
here is the assembly code
;
; file: ZIJ.s
;
.text
.global _ZIJ
_ZIJ:
CORCON = 0x00F ; Signed, saturation, fractional computing
SRbits.OV = 1 ; Overflow for signed arithmetic
mov #_Rijn, W8; ; W8 pointer
mov #_Vs, W10; ; W10 pointer
mov _Gx, W2; ; Move Gx to W2
mov _Refl, W3; ; Move Refl to W3
sub W3, W2, [W10]; ; Calculate V = W3 - W2
movsac A,[W8]+=2,W4,[W10]+=2,W5; ; Move Rijn1
mac W4*W5,B,[W8]+=2,W4,[W10]+=2,W5; ;Mult W4xW5 store and prefetch
mac W4*W5,B,[W8]+=2,W4,[W10]+=2,W5;; Mult W4xW5 store and prefetch
mac W4*W5,B,[W8],W4,[W10]-=2,W5; ; Mult W4xW5, store and point
sac.r B, #-8, W0; ; Shift acc B 8 bits to left and store in W0
mov W5, [W10]; ; Copy the content of W5 into W10
mov [W10 + -#4], W5; ; Copy content of W10-4 to W5
mov W5, [--W10]; ; Copy W5 to locn pointed to by W10
mov W0, _Zout; ; Copy W0 to Zout
return
.end
thanks,
dsprogrammer