⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stepper.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
02D1 0001                    
02D3 010200     =1   580             DB      1, 2, 0         ; Manufacturer, Product & Serial# Names
A51 MACRO ASSEMBLER  STEPPER                                                                22/07/99 14:17:14 PAGE    10

02D6 01         =1   581             DB      1               ; #Configs
02D7            =1   582     ConfigurationDescriptor:
02D7 0902       =1   583             DB      9, 2            ; Length, Type
02D9 1B00       =1   584             DB      LOW(ConfigLength), HIGH(ConfigLength)
02DB 010100     =1   585             DB      1, 1, 0         ; #Interfaces, Configuration#, Config. Name
02DE 80         =1   586             DB      10000000b       ; Attributes = Bus Powered
02DF 32         =1   587             DB      50              ; Max. Power is 50x2 = 100mA
02E0            =1   588     InterfaceDescriptor:
02E0 0904       =1   589             DB      9, 4            ; Length, Type
02E2 000000     =1   590             DB      0, 0, 0         ; No alternate setting, HID OUTPUT uses EP0
02E5 03         =1   591             DB      3               ; Class = Human Interface Device
02E6 0000       =1   592             DB      0, 0            ; Subclass and Protocol
02E8 00         =1   593             DB      0               ; Interface Name
02E9            =1   594     HIDDescriptor:
02E9 0921       =1   595             DB      9, 21H          ; Length, Type
02EB 0001       =1   596             DB      0, 1            ; HID Class Specification compliance
02ED 00         =1   597             DB      0               ; Country localization (=none)
02EE 01         =1   598             DB      1               ; Number of descriptors to follow
02EF 22         =1   599             DB      22H             ; And it's a Report descriptor
02F0 1700       =1   600             DB      LOW(ReportLength), HIGH(ReportLength)
  001B          =1   601     ConfigLength    EQU $ - ConfigurationDescriptor
                =1   602     
02F2            =1   603     ReportDescriptor:               ; Generated with HID Tool, copied to here
02F2 0600FF     =1   604             DB      6, 0, 0FFH      ; Usage_Page (Vendor Defined)
02F5 0901       =1   605             DB      9, 1            ; Usage (I/O Device)
02F7 A101       =1   606             DB      0A1H, 1         ; Collection (Application)
02F9 1901       =1   607             DB      19H, 1          ;   Usage_Minimum
02FB 2902       =1   608             DB      29H, 2          ;   Usage_Maximum
02FD 1500       =1   609             DB      15H, 0          ;   Logical_Minimum (0)
02FF 26FF00     =1   610             DB      26H, 255, 0     ;   Logical_Maximum (255)
0302 7508       =1   611             DB      75H, 8          ;   Report_Size (8)
0304 9503       =1   612             DB      95H, 3          ;   Report_Count (3) = Motor Control
0306 9102       =1   613             DB      91H, 2          ;   Output (Data,Var,Abs)
0308 C0         =1   614             DB      0C0H            ; End_Collection
  0017          =1   615     ReportLength    EQU $-ReportDescriptor
                =1   616              
0309            =1   617     String0:                        ; Declare the UNICODE strings
0309 04030904   =1   618             DB      4, 3, 9, 4      ; Only English language strings supported
030D            =1   619     String1:                        ; Manufacturer
030D 2C03       =1   620             DB      (String2-String1),3 ; Length, Type 
030F 55005300   =1   621             DB      "U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
0313 42002000                
0317 44006500                
031B 73006900                
031F 67006E00                
0323 2000                    
0325 42007900   =1   622             DB      "B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
0329 20004500                
032D 78006100                
0331 6D007000                
0335 6C006500                
0339            =1   623     String2:                        ; Product Name
0339 1C03       =1   624             DB      (EndOfDescriptors-String2),3
033B 53007400   =1   625             DB      "S",0,"t",0,"e",0,"p",0,"p",0,"e",0,"r",0," ",0
033F 65007000                
0343 70006500                
0347 72002000                
034B 4D006F00   =1   626             DB      "M",0,"o",0,"t",0,"o",0,"r",0
034F 74006F00                
0353 7200                    
0355            =1   627     EndOfDescriptors:
0355 0000       =1   628             DW      0               ; Backstop for String Descriptors
                =1   629     
                =1   630     
                =1   631     
                     632     $INCLUDE(Main.A51)
A51 MACRO ASSEMBLER  STEPPER                                                                22/07/99 14:17:14 PAGE    11

                =1   633     ; This module initializes the microcontroller then executes MAIN forever
                =1   634     ;
                =1   635     
0357            =1   636     Reset:
0357 7581EB     =1   637             MOV     SP, #235                ; Initialize the Stack at top of internal memory
035A 75927F     =1   638             MOV     PageReg, #7FH           ; Needed to use MOVX @Ri
                =1   639     
035D 78D6       =1   640             MOV     R0, #LOW(USBControl)    ; Simulate a disconnect
035F E2         =1   641             MOVX    A, @R0
0360 54F3       =1   642             ANL     A, #11110011b           ; Clear DISCON, DISCOE
0362 F2         =1   643             MOVX    @R0, A
0363 120390     =1   644             CALL    Wait100msec             ; Give the host time to react
0366 E2         =1   645             MOVX    A, @R0                  ; Reconnect with this new identity
0367 4406       =1   646             ORL     A, #00000110b           ; Set DISCOE to enable pullup resistor
0369 F2         =1   647             MOVX    @R0, A                  ; Set RENUM so that 8051 handles USB requests
036A E4         =1   648             CLR     A
036B F520       =1   649             MOV     FLAGS, A                ; Start in Default state
036D            =1   650     InitializeIOSystem:                     ; This example uses only Port A output
036D 7893       =1   651             MOV     R0, #LOW(PortA_Config)  ; PageReg = 7F = HIGH(PortA_Config)
036F E4         =1   652             CLR     A
0370 F2         =1   653             MOVX    @R0, A                  ; No alternate functions
0371 799C       =1   654             MOV     R1, #LOW(PortA_OE)
0373 F4         =1   655             CPL     A                       ; = 0FFH
0374 F3         =1   656             MOVX    @R1, A                  ; Enable PortA for Output
0375            =1   657     InitializeInterruptSystem:              ; First initialize the USB level
0375 78AC       =1   658             MOV     R0, #LOW(IN07IEN)
0377 F2         =1   659             MOVX    @R0, A                  ; Disable interrupts from IN Endpoints 0-7
0378 08         =1   660             INC     R0
0379 F2         =1   661             MOVX    @R0, A                  ; Disable interrupts from OUT Endpoints 0-7
037A 08         =1   662             INC     R0
037B 7403       =1   663             MOV     A, #00000011b
037D F2         =1   664             MOVX    @R0, A                  ; Enable (Resume, Suspend,) SOF and SUDAV INTs
037E 08         =1   665             INC     R0
037F 7401       =1   666             MOV     A, #00000001b
0381 F2         =1   667             MOVX    @R0, A                  ; Enable Auto Vectoring for USB interrupts
0382 78AA       =1   668             MOV     R0, #LOW(OUT07IRQ)
0384 74FF       =1   669             MOV     A, #0FFH
0386 F2         =1   670             MOVX    @R0, A                  ; Clear out any pending interrupts
                =1   671                                             ; Now enable the main level
0387 75E801     =1   672             MOV     EIE, #00000001b         ; Enable INT2 = USB Interrupt (only)            
038A 75A8C0     =1   673             MOV     EI, #11000000b          ; Enable interrupt subsystem (and Ser1 for Dscope)
                =1   674      
                =1   675     ; Initialization Complete.
                =1   676     ; 
038D            =1   677     MAIN:
038D 00         =1   678             NOP                             ; Not much of a main loop for this example
038E 80FD       =1   679             JMP     MAIN                    ; All actions are initiated by interrupts
                =1   680     ; We are a slave, we wait to be told what to do
                =1   681     
0390            =1   682     Wait100msec:
0390 754064     =1   683             MOV     Temp, #100
0393            =1   684     Wait1msec:                              ; A delay loop
0393 90FB50     =1   685             MOV     DPTR, #-1200            
0396 A3         =1   686     More:   INC     DPTR                    ; 3 cycles
0397 E582       =1   687             MOV     A, DPL                  ; + 2
0399 4583       =1   688             ORL     A, DPH                  ; + 2
039B 70F9       =1   689             JNZ     More                    ; + 3 = 10 cycles x 1200 = 1msec
039D D540F3     =1   690             DJNZ    Temp, Wait1msec
03A0 22         =1   691             RET
                =1   692     
03A1            =1   693     ProcessOutputReport:                    ; A Report has just been received
                =1   694     ; The report is three bytes long
                =1   695     ; Save the values for the INTERRUPT service routine
03A1 7846       =1   696             MOV     R0, #MotorControl       ; Initialize the pointers to be used
03A3 907EC0     =1   697             MOV     DPTR, #EP0OutBuffer     ; Point to the Report
03A6 7F03       =1   698             MOV     R7, #3
A51 MACRO ASSEMBLER  STEPPER                                                                22/07/99 14:17:14 PAGE    12

03A8 E0         =1   699     CopyOR: MOVX    A, @DPTR                ; Retrieve Report Byte 1
03A9 F6         =1   700             MOV     @R0, A
03AA A3         =1   701             INC     DPTR
03AB 08         =1   702             INC     R0
03AC DFFA       =1   703             DJNZ    R7, CopyOR
03AE 22         =1   704             RET
                =1   705     
03AF            =1   706     CreateInputReport:
                =1   707     ; Not used in this example
                =1   708     
                =1   709     
                     710     $INCLUDE(Timer.A51)
                =1   711     ; This module services the real time interrupt
                =1   712     ;
                =1   713     ; Get a Real Time interrupt every One millisecond (using SOF interrupt)
                =1   714     ;
                =1   715     ; Pulse the stepper motor every 10msec (100Hz) if required
                =1   716     ;       EZ-USB PortA drives an Allegro 8219
                =1   717     ;       Phase A is connected to bits 5,4 & 3, Phase B to bits 2,1 & 0
                =1   718     ;       Bits 5 and 2 are PHASE
                =1   719     ;       Bits 4:3 and 1:0 are I1:I0 current inputs
                =1   720     ;
03AF            =1   721     ServiceTimerRoutine:
03AF D54924     =1   722             DJNZ    Msec_counter, Done      ; Only need to step every 10msec
03B2 75490A     =1   723             MOV     Msec_counter, #10       ; Reinitialize
                =1   724     
03B5 7847       =1   725             MOV     R0, #MotorControl+1     ; Point to LS byte of count
03B7 7948       =1   726             MOV     R1, #MotorControl+2     ; Point to MS byte of count
03B9 E6         =1   727             MOV     A, @R0
03BA 47         =1   728             ORL     A, @R1
03BB 6019       =1   729             JZ      Done                    ; No stepping required
03BD            =1   730     StepTheMotor:
03BD 16         =1   731             DEC     @R0                     ; Unfortunately, no flags are set
03BE E6         =1   732             MOV     A, @R0
03BF F4         =1   733             CPL     A                       ; Test for LS = FF
03C0 6001       =1   734             JZ      STM1
03C2 17         =1   735             DEC     @R1                     ; Underflow on LS, therefore adjust MS byte
03C3 E546       =1   736     STM1:   MOV     A, MotorControl         ; Get the direction indicator
03C5 7002       =1   737             JNZ     Clockwise
03C7 74FF       =1   738             MOV     A, #-1                  ; CounterClockwise = backup one
03C9            =1   739     Clockwise:
03C9 2549       =1   740             ADD     A, CurrentPosition
03CB 540F       =1   741             ANL     A, #0FH                 ; Table is only 16 entries long
03CD F549       =1   742             MOV     CurrentPosition, A
03CF 9003D7     =1   743             MOV     DPTR, #StepperTable
03D2 93         =1   744             MOVC    A, @A + DPTR            ; Index into table 
03D3 7899       =1   745             MOV     R0, #Low(PortA_Pins)
03D5 F2         =1   746             MOVX    @R0, A                  ; Select the new step position
03D6 22         =1   747     Done:   RET
                =1   748     
03D7            =1   749     StepperTable:
03D7 07         =1   750             DB 000111b      ;  0 = Up
03D8 02         =1   751             DB 000010b      ;  1
03D9 09         =1   752             DB 001001b      ;  2
03DA 10         =1   753             DB 010000b      ;  3
03DB 18         =1   754             DB 011000b      ;  4 = Right
03DC 30         =1   755             DB 110000b      ;  5
03DD 29         =1   756             DB 101001b      ;  6
03DE 22         =1   757             DB 100010b      ;  7
03DF 23         =1   758             DB 100011b      ;  8 = Down
03E0 26         =1   759             DB 100110b      ;  9
03E1 2D         =1   760             DB 101101b      ; 10
03E2 34         =1   761             DB 110100b      ; 11

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -