C to ASM

MK info@mcu.cz
Sobota Srpen 13 11:33:54 CEST 2005


; unsigned char code promenna[] = {0,1,2,3,4,5,6,7,8,9};
;                                          /* is enabled 
*/
;
; //Sine wave table used for 4-bit microstepping.
; //The absolute values are left-shifted by one bit, and bit 0 is the sign 
bit (phase direction bit)
; //Bit 5 is the mixed decay bit. It is set when the absolute value is 
falling
; unsigned char sinus_tab[64]={0x00, 0x02, 0x06, 0x08, 0x0c, 0x0e, 0x10, 
0x14,
;                        0x16, 0x18, 0x18, 0x1a, 0x1c, 0x1c, 0x1e, 0x1e,
;                        0x3e, 0x3e, 0x3e, 0x3c, 0x3c, 0x3a, 0x38, 0x38,
;                        0x36, 0x34, 0x30, 0x2e, 0x2c, 0x28, 0x26, 0x22,
;                        0x01, 0x03, 0x07, 0x09, 0x0d, 0x0f, 0x11, 0x15,
;                        0x17, 0x19, 0x19, 0x1b, 0x1d, 0x1d, 0x1f, 0x1f,
;                        0x3f, 0x3f, 0x3f, 0x3d, 0x3d, 0x3b, 0x39, 0x39,
;                        0x37, 0x35, 0x31, 0x2f, 0x2d, 0x29, 0x27, 0x23};
;
; volatile unsigned char PhaseCount=0;
;
;
;
; /**********************************************************
;   This function generates the
;   microsteps. The values are read from the
;   table and output to the TMC236 or TMC239
;   via the SPI interface.
;   Call this function with the "ccw" parameter set to 1
;   to step in negative direction,
;   or with "ccw" set to 0 to step in positive direction.
;   Callthis function for example in a timer interrupt.
; ***********************************************************/
; void step(char ccw){

 RSEG  ?PR?_step?HELLO
_step:
 USING 0
   ; SOURCE LINE # 48
;---- Variable 'ccw?040' assigned to Register 'R7' ----
;   unsigned int MixedDecayXOR=0, io;
   ; SOURCE LINE # 49
;---- Variable 'MixedDecayXOR?041' assigned to Register 'R4/R5' ----
 CLR   A
 MOV   R5,A
 MOV   R4,A
;
;   if(!ccw){
   ; SOURCE LINE # 51
 MOV   A,R7
 JNZ   ?C0001
;     PhaseCount++;
   ; SOURCE LINE # 52
 INC   PhaseCount
;   }
   ; SOURCE LINE # 53
 SJMP  ?C0002
?C0001:
;   else{     //The "Mixed Decay" bits must be reversed when running in CCW 
direction
   ; SOURCE LINE # 54
;     PhaseCount--;
   ; SOURCE LINE # 55
 DEC   PhaseCount
;     MixedDecayXOR=0x820;
   ; SOURCE LINE # 56
 MOV   R4,#08H
 MOV   R5,#020H
;   }
   ; SOURCE LINE # 57
?C0002:
;   io=((sinus_tab[PhaseCount & 63]<<6 | sinus_tab[(PhaseCount+16) & 63]) ^ 
MixedDecayXOR);
   ; SOURCE LINE # 58
 MOV   A,PhaseCount
 ANL   A,#03FH
 ADD   A,#LOW (sinus_tab)
 MOV   R0,A
 MOV   A,@R0
 MOV   B,#040H
 MUL   AB
 MOV   R7,A
 MOV   A,PhaseCount
 ADD   A,#010H
 ANL   A,#03FH
 ADD   A,#LOW (sinus_tab)
 MOV   R0,A
 MOV   A,@R0
 MOV   R3,A
 MOV   A,R7
 ORL   A,R3
 MOV   R7,A
 MOV   A,B
 XRL   A,R4
 MOV   io?042,A
 MOV   A,R7
 XRL   A,R5
 MOV   io?042+01H,A
;
;   //Now, set the CS line of the TMC236/239 low and send out the value of 
"io" by SPI
;   //(MSB first).
;   //After that, set the CS line high again.
; }
   ; SOURCE LINE # 63
 RET
; END OF _step



Co je v kodu jsem neresil, jen jsem to prohnal C51

S pozdravem
MK 




Další informace o konferenci Hw-list