1、/ Returnvalue (ib * 16 , (ia * 16/-/ Parameters/-/ Date 09.01.2005/ Condition optimization off / one/* inline int clarke_trans(int Phase_s, int Phase_t, int *iaint retvalue;_asm( mov r12,MCW n mov MCW,#0200h ; set saturation n shl %2,#1 ; ( 2*Phase_t n add %2,%1 ; + Phase_s n mov r13,#37837 n CoMULs
2、u %2,r13 ;* 1/sqrt(3 n CoSHL #4 ; default 2 * 4 n CoSTORE %0,MAS ; ib = result n shl %1,#2 n mov %3,%1 ; ia = Phase_s * 4 n mov MCW,r12 n: =&w(retvalue /* output registers */(Phase_s,(Phase_t,(ia /* input registers */r13,r12/*scratch registers */;return retvalue;/* / Function int park_trans(int e_a,
3、int e_b,int phi,int *a_b/-/ Description park transformation/-/ Returnvalue Id_comp , Iq_compinline int park_trans(int i_a,int i_b,int phi,int *o_q_asm( n mov r13,MCW n mov MCW,#0600h n shr %3,#6 n shl %3,#1 n EXTS #SEG (_sincostab,#2 n mov r11,%3 + #SOF(_sincostab+512 n mov r12,%3 + #SOF(_sincostab
4、n CoMUL %2,r12 n CoMAC %1,r11 n CoSTORE %0,MAS n CoMUL %2,r11 n CoMAC- %1,r12 n CoSTORE %4,MAS n mov MCW,r13 n(i_a,(i_b,(phi,(o_q /* input registers */r11/*/ /* / Function int inv_park_trans(int e_a,int e_b,int phi,int *a_b/-/ Description inverse park transformation/-/ Returnvalue I_alpha , I_beta/*
5、 inline int inv_park_trans(int i_d,int i_q,int phi,int *o_b mov r12,%3 + #SOF(_sincostab+512 n mov r11,%3 + #SOF(_sincostab n CoMUL %1,r12 n CoMAC- %2,r11 n CoASHR #2 n CoMUL %1,r11 n CoMAC %2,r12 n(i_d,(i_q,(o_b /* input registers */ :/* / Function int cart_polar_conv(int x,int y, int *angle;/-/ De
6、scription/-/ Returnvalue/* unsigned int cart_polar_conv(int x,int y, int *angleunsigned int retvalue; enable saturation to +/-0x7fff n mov r13,%1 ; r13 = x n jmpr cc_nn,kpw1co ; if (x = 0 goto kpw1co n neg r13 ; else r13 = -r13 nkpw1co: ; r13 = |x| n mov r12,%2 ; r12 = y n jmpr cc_nn,kpw2co ; if (y
7、= 0 goto kpw2co n neg r12 ; r12 = -r12 nkpw2co: r12 = |y| n mov r9,#1024 n cmp r13,r12 n jmpr cc_c,kpw3co ; if( x signed n %0 = CoACC n EXTS #SEG (_phitab,#1 n mov r10,r9+#SOF(_phitab ; r10 = arctan( y/x n cmp %1,#0 ; n jmpr cc_n,kpw4co ; if ( x 0 goto kpw4co n cmp %2,#0 n jmpr cc_n,kpw5co ; if ( y
8、0 and y 0 n neg r10 n angle = -arctan( y/x nkpw4co: x cmp %2,#0 ; jmpr cc_n,kpw6co ; 0 goto kpw6co n mov r9,#8000h n sub r9,r10 n mov %3,r9 ; angle = 180- arctan( y/x nkpw6co: add r10,#8000h n angle = -180+ arctan( y/x nkpw3co: |x| |y| n mulu r13,r9 ; MD = |x| * 1024 n divlu r12 ; MDL = MD / |y| n C
9、oMULu r12,r10 ; cmp %1,#0 n jmpr cc_n,kpw7co ; 0 goto kpw7co n jmpr cc_n,kpw8co ; 0 goto kpw8co n mov r9,#4000h n angle = 90- arctan( x/y = 90- arccot( y/x = arctan( y/x nkpw8co: add r10,#0C000h n angle = -90+ arctan( x/y = -(90- arccot( y/x = -arctan( y/x nkpw7co: jmpr cc_n,kpw9co ; 0 goto kpw9co n
10、 add r10,#4000h n angle = 90+ arctan( x/y = 180- (90- arccot( y/x = 180- arctan( y/x nkpw9co: mov r9,#0C000h n sub r9,r10 ; angle = -90- arctan( x/y = -180+ (90- arccot( y/x = -180+ arctan( y/x n mov %3,r9 nendco:(x,(y,(angle /* input registers */r10r9/* / Function: a low pass filter 2012-9-13 17:58
11、:43/ C calling format:/ int inline int pt1_controller32( int *pt1_parameter, int X/ PT1-Controller/ derived from transfer function/ Y_(k = Y_(k-1 + Z1_(k * X_(k - Z2_(k * Y_(k-1/-/ Computing time 42 CPU-cycle/ int 3 Output of pt1_controller/-/ Condition optimization off / one/*inline int pt1_controller32( PT1_array *pt1_parameter, int X/inline int pt1_controller32( int *pt1_parameter, int X mov r10,MCW ;Save MCW register n mov MCW,#0400h ;Set shift left n mov %0,%1+ n CoLOAD %0,%1 ;Load Y(k-1 in accumulator nSave parameters addres in %1 n add r13,#2 n
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1